better files completion in git repo

This commit is contained in:
Felix Van der Jeugt 2017-10-17 10:07:22 +02:00
parent 08459c6382
commit b2785649c8
No known key found for this signature in database
GPG Key ID: 58B209295023754D

5
bashrc
View File

@ -40,6 +40,9 @@ _comp_git() {
# remotes # remotes
COMPREPLY+=( $(git remote | grep "^$2") ) COMPREPLY+=( $(git remote | grep "^$2") )
# files
COMPREPLY+=( $(git ls-files -co --exclude-standard | grep "^$2") )
# subcommands # subcommands
if [ "$3" = "git" ]; then if [ "$3" = "git" ]; then
COMPREPLY+=( $({ compgen -c "git-"; command ls /usr/libexec/git-core; } | sed -n 's/^git-//p' | grep "^$2") ) COMPREPLY+=( $({ compgen -c "git-"; command ls /usr/libexec/git-core; } | sed -n 's/^git-//p' | grep "^$2") )
@ -50,7 +53,7 @@ complete -c man
complete -cf sudo complete -cf sudo
complete -cf exec complete -cf exec
complete -cf run complete -cf run
complete -fF _comp_git git complete -F _comp_git git
# history # history
export HISTCONTROL=ignorespace:erasedups export HISTCONTROL=ignorespace:erasedups