i use alias which adds some parameters to some program.
for example:
alias git.home='git --git-dir=$HOME/.git.home/'
complete -o bashdefault -o default -o nospace -F _git git.home \
2>/dev/null || complete -o default -o nospace -F _git git.home
it works with bash-completion v.1:2.0-1
("debian 7 wheezy"):
tab completes parameters and options for alias git.home
as well as for "original" git
.
but with bash-completion v.1:2.1-4
("debian 8 jessie") after typing git.home
and pressing tab i get this error:
bash: completion: function `_git' not found
how to re-use existing completion (for example for git
) with recent versions of package bash-completion
?
update
found partial solution: do source /usr/share/bash-completion/completions/git
before complete ...
but i get another error - git.home log
+ space + tab results in:
fatal: Not a git repository (or any of the parent directories): .git HEAD
git log
shows history for the repo in./.git/
, andgit.home log
shows history for the repo in~/.git.home/
. and completion of branches in both cases is working correctly. – aleksandr barakin Jul 18 '15 at 10:20git log<space><tab>
? What do you see forgit --git-dir=.git log<space><tab>
in~/bash_completion
? – Evgeny Jul 18 '15 at 10:33~/.bashrc
and re-login. 3.cp -a /some/repo/.git ~/.git.home
. 4.cd
. 5. trygit.home log
,git.home status
etc.~/.git.home
– aleksandr barakin Jul 18 '15 at 10:52cd
,git.home log
,git.home status
works fine. butgit log<space><tab>
always showsgit --git-dir=$HOME/.git.home for-each-ref '--format=%(refname:short)' refs/tags refs/heads refs/remotes
andHEAD
. i.e.git.home
completion affectsgit
completion – Evgeny Jul 18 '15 at 11:03git-dir
ingit.home
completion was a real bug – Evgeny Jul 19 '15 at 15:25