From 90e64802042d8551a99490481fa14b743a8d7b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20B=C3=BCckendorf?= Date: Thu, 6 Dec 2018 19:10:53 +0100 Subject: [PATCH] dotfiles.bashrc: Expanded on the routine by which dotfile and dot aliases are introduced --- .bashrc.d/dotfiles.bashrc | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.bashrc.d/dotfiles.bashrc b/.bashrc.d/dotfiles.bashrc index 8b7ebfc..c425d7f 100644 --- a/.bashrc.d/dotfiles.bashrc +++ b/.bashrc.d/dotfiles.bashrc @@ -1,2 +1,32 @@ -alias dotfiles="git -c include.path=$HOME/.dotfiles/dotgit_config --git-dir=$HOME/.dotgit/ --work-tree=$HOME" -complete -o bashdefault -o default -o nospace -F __git_wrap__git_main dotfiles +# Alias dotfiles to the custom git command required for the functioning of the +# dotfiles utility +dotgit_config="$HOME/.dotfiles/dotgit_config" +dotgit_dir="$HOME/.dotgit/" +alias dotfiles="git -c include.path=$dotgit_config --git-dir=$dotgit_dir --work-tree=$HOME" + +# Shorten the dotfiles command to dot if possible +if ! command -v dot >/dev/null 2>&1 +then + alias dot="dotfiles" + dot_aliased="yes" +fi + +# Add bash completion to the aliases if possible +possible_locations=( + "/usr/share/doc/git/contrib/completion/git-completion.bash" + "/usr/share/git/completion/git-completion.bash" +) + +for completion_file in "${possible_locations[@]}" +do + if [[ -r "$completion_file" ]] + then + . $completion_file + __git_complete dotfiles __git_main + if [[ dot_aliased == "yes" ]] + then + __git_complete dot __git_main + fi + break + fi +done