write simple git completion for bash
This commit is contained in:
parent
c703a6f0df
commit
45f04eaa57
19
bashrc
19
bashrc
@ -28,10 +28,29 @@ unset GREEN
|
|||||||
unset RESET
|
unset RESET
|
||||||
|
|
||||||
# Completion
|
# Completion
|
||||||
|
_comp_git() {
|
||||||
|
local IFS=$'\n'
|
||||||
|
# $1 is the name of the command whose arguments are being completed
|
||||||
|
# $2 is the word being completed
|
||||||
|
# $3 is the word preceding the word being completed
|
||||||
|
|
||||||
|
# branch names
|
||||||
|
COMPREPLY=( $(git branch -a --format "%(refname:short)" | grep "^$2") )
|
||||||
|
|
||||||
|
# remotes
|
||||||
|
COMPREPLY+=( $(git remote | grep "^$2") )
|
||||||
|
|
||||||
|
# subcommands
|
||||||
|
if [ "$3" = "git" ]; then
|
||||||
|
COMPREPLY+=( $({ compgen -c "git-"; command ls /usr/libexec/git-core; } | sed -n 's/^git-//p' | grep "^$2") )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
complete -c man
|
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
|
||||||
|
|
||||||
# history
|
# history
|
||||||
export HISTCONTROL=ignorespace:erasedups
|
export HISTCONTROL=ignorespace:erasedups
|
||||||
|
@ -18,3 +18,4 @@
|
|||||||
pushf = push --force-with-lease
|
pushf = push --force-with-lease
|
||||||
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
|
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
|
||||||
ff = merge --ff-only
|
ff = merge --ff-only
|
||||||
|
co = checkout
|
||||||
|
Loading…
Reference in New Issue
Block a user