~ / .bashrc
_git_xxx ()
{
_git_rebase
}
~ / .gitconfig
[alias]
xxx = !bash -c 'git rebase ...'
Например, _git_rebase
выглядит следующим образом (встречается в git-complete.bash - путь к этому файлу зависит от вашей системы, используйте locate
, find
, что угодно, чтобы найти его):
_git_rebase ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
__gitcomp "--continue --skip --abort --quit --edit-todo"
return
elif [ -d "$__git_repo_path"/rebase-apply ] || \
[ -d "$__git_repo_path"/rebase-merge ]; then
__gitcomp "--continue --skip --abort --quit"
return
fi
__git_complete_strategy && return
case "$cur" in
--whitespace=*)
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
--*)
__gitcomp "
--onto --merge --strategy --interactive
--preserve-merges --stat --no-stat
--committer-date-is-author-date --ignore-date
--ignore-whitespace --whitespace=
--autosquash --no-autosquash
--fork-point --no-fork-point
--autostash --no-autostash
--verify --no-verify
--keep-empty --root --force-rebase --no-ff
--exec
"
return
esac
__git_complete_refs
}
Скопируйте эту функцию, например, переименуйте в _git_whatever
измените его так, как вам нравится, и вставьте его в ~/.bashrc
, затем используйте __git_complete gwhat _git_whatever
, чтобы сделать из него псевдоним.
Завершение будет работать из коробки на git whatever<TAB><TAB>
без шага __git_complete ...
.
Чтобы предотвратить дублирование кода, вы можете привязать свой псевдоним завершения к существующему:
_git_xxx ()
{
_git_rebase
}