我创建了git别名~/.gitconfig
:
[alias]
xxx = !bash -c 'git rebase ...'
有没有办法让bash自动完成git xxx
?像通常的别名一样:
__git_complete grb _git_rebase
发布于 2018-06-05 11:45:34
〜/ .bashrc:
_git_xxx ()
{
_git_rebase
}
〜/.gitconfig
[alias]
xxx = !bash -c 'git rebase ...'
_git_rebase
看起来像这样:
_git_rebae ()
{
__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_xxx ()
{
_git_rebase
}
https://stackoverflow.com/questions/-100008628
复制相似问题