dotfiles script v0.4.2

- change bash completion from single file to per-directory (~/.bash_completion.d/)
This commit is contained in:
Lexi Stelter 2019-02-19 15:47:19 +01:00
parent 1764e39cb8
commit 9b2fa59ed8
3 changed files with 32 additions and 10 deletions

View File

@ -1,8 +1,11 @@
# ~/.bash_completion - Custom bash auto completions
# Enable bash completion for dotfiles manager (if installed)
[[ -x "$HOME/bin/dotfiles" ]] && source <($HOME/bin/dotfiles bash-completion)
shopt -s nullglob
# Include host-specific bash_completion
[[ -f ~/.bash_completion.local ]] && source ~/.bash_completion.local
# Include all files from ~/.bash_completion.d/
if [[ -d ~/.bash_completion.d ]]; then
for f in ~/.bash_completion.d/*; do
[[ -f "$f" ]] && . "$f"
done
fi

View File

@ -0,0 +1,3 @@
# Enable bash completion for dotfiles manager (if installed)
[[ -x "$HOME/bin/dotfiles" ]] && source <($HOME/bin/dotfiles bash-completion)

View File

@ -2,7 +2,7 @@
##
## binaryDiv's dotfiles management script
## Version 0.4.1
## Version 0.4.2
##
usage() {
@ -74,11 +74,27 @@ case "$cmd" in
echo "! Warning: $bin_dir is not in your PATH."
fi
# Activate bash completion
if [[ ! -e "$homedir/.bash_completion" ]]; then
echo "* Installing user-defined bash completion"
"$0" link -q .bash_completion &&
echo " Restart bash or run 'source $homedir/.bash_completion' to activate it now"
show_bash_restart_info=
# Enable user-defined bash completion per directory
bashcompletion_filename=.bash_completion
if [[ ! -e "$homedir/$bashcompletion_filename" ]]; then
echo "* Installing user-defined bash completion (~/.bash_completion.d/)"
"$0" link -q "$bashcompletion_filename" &&
show_bash_restart_info=1
fi
mkdir -p "$homedir/.bash_completion.d"
# Activate dotfiles bash completion
bashcompletion_dotfiles_filename=.bash_completion.d/10-dotfiles.sh
if [[ ! -e "$homedir/$bashcompletion_dotfiles_filename" ]]; then
echo "* Installing bash completion for dotfiles script"
"$0" link -q "$bashcompletion_dotfiles_filename" &&
show_bash_restart_info=1
fi
if [[ -n $show_bash_restart_info ]]; then
echo " Restart bash or run 'source $homedir/.bash_completion' to activate it now"
fi
echo "* Configuring git settings"