In my git config, I have a relatively long alias which outputs a log of recent git commits in a pretty format:
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'
I also have another alias which builds on the previous one by adding the --all
option the the command. I didn't want to repeat myself by specifying the entire command string in both aliases, so I just had my new alias shell out to the previous one:
la = !git lg --all
This works quite well, but there's a problem: while autocompletion of branch names works fine with my regular git lg
alias, it doesn't work at all for the one that shells out.
How can I make autocompletion of git branch names work with aliases that shell out to other commands?
Note: This question is distinct from How do I get bash completion to work with aliases? , because that question deals with bash aliases of git commands, and not git's built-in alias system.
In this case typing any branch name would give the same results because --all
option shows all refs. However if you add
function _git_la() {
_git_log
}
to your shell startup file it should autocomplete correctly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.