Create __install_bash_completions function
This commit is contained in:
45
bootstrap.sh
45
bootstrap.sh
@@ -1,5 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# complete_alias is a script that allows to use completion in aliases
|
||||||
|
declare -A bashCompletions=(
|
||||||
|
["complete_alias"]="https://raw.githubusercontent.com/cykerway/complete-alias/master/complete_alias"
|
||||||
|
["tmux"]="https://raw.githubusercontent.com/Bash-it/bash-it/master/completion/available/tmux.completion.bash"
|
||||||
|
["git"]="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
|
||||||
|
)
|
||||||
|
|
||||||
declare -A configs=(
|
declare -A configs=(
|
||||||
["$PWD/config/.bashrc"]="$HOME/.bashrc"
|
["$PWD/config/.bashrc"]="$HOME/.bashrc"
|
||||||
["$PWD/config/.inputrc"]="$HOME/.inputrc"
|
["$PWD/config/.inputrc"]="$HOME/.inputrc"
|
||||||
@@ -21,6 +28,23 @@ declare -A configs=(
|
|||||||
|
|
||||||
bashCompletionsDir="$HOME/.config/bash-completions"
|
bashCompletionsDir="$HOME/.config/bash-completions"
|
||||||
|
|
||||||
|
__install_bash_completions() {
|
||||||
|
if [[ ! -d "$bashCompletionsDir" ]] ; then
|
||||||
|
mkdir "$bashCompletionsDir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for cmp in "${!bashCompletions[@]}"
|
||||||
|
do
|
||||||
|
source=${bashCompletions[$cmp]}
|
||||||
|
dest="$bashCompletionsDir/$cmp.bash"
|
||||||
|
|
||||||
|
if [[ ! -f "$dest" ]] ; then
|
||||||
|
echo "Downloading $cmp completion"
|
||||||
|
curl "$source" -o "$dest" &> /dev/null
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: (./)bootstrap.sh [-S][-R]"
|
echo "usage: (./)bootstrap.sh [-S][-R]"
|
||||||
@@ -52,6 +76,10 @@ git clone --depth 1 https://github.com/wbthomason/packer.nvim \
|
|||||||
# Install vim plugins
|
# Install vim plugins
|
||||||
nvim -c "PackerInstall"
|
nvim -c "PackerInstall"
|
||||||
|
|
||||||
|
if [[ ! -d "$bashCompletionsDir" ]] ; then
|
||||||
|
__install_bash_completions
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove all configs
|
# Remove all configs
|
||||||
@@ -67,23 +95,8 @@ rm -rf "$bashCompletionsDir"
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# complete_alias is a script that allows to use completion in aliases
|
|
||||||
declare -A bashCompletions=(
|
|
||||||
["complete_alias"]="https://raw.githubusercontent.com/cykerway/complete-alias/master/complete_alias"
|
|
||||||
["tmux"]="https://raw.githubusercontent.com/Bash-it/bash-it/master/completion/available/tmux.completion.bash"
|
|
||||||
["git"]="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install bash completions defined in hashmap above
|
# Install bash completions defined in hashmap above
|
||||||
if [ "$1" = "-I" ] ; then
|
if [ "$1" = "-I" ] ; then
|
||||||
for cmp in "${!bashCompletions[@]}"
|
__install_bash_completions
|
||||||
do
|
|
||||||
source=${bashCompletions[$cmp]}
|
|
||||||
dest="$bashCompletionsDir/$cmp.bash"
|
|
||||||
|
|
||||||
if [[ ! -f "$dest" ]] ; then
|
|
||||||
echo "Downloading $cmp completion"
|
|
||||||
curl "$source" -o "$dest" &> /dev/null
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user