我正在尝试创建git别名与自动完成使用The Ultimate Git Alias Setup。我执行了指令中的所有操作,但将以下内容放入我的.zshrc文件会导致错误:
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
function_exists() {
declare -f -F $1 > /dev/null
return $?
}
for al in `__git_aliases`; do
alias g$al="git $al"
complete_func=_git_$(__git_aliased_command $al)
function_exists $complete_fnc && __git_complete g$al $complete_func
done
错误不直观:.zshrc:153: parse error near
\n'`
但是尝试在命令行中运行__git_aliases
会产生:zsh: command not found: __git_aliases
,所以我认为这就是问题所在。
然后我在网上发现,这可能是git的弃用,这一行应该给出相同的输出:
git config --global alias.aliases "config --get-regex 'alias*'"
,
但这并不管用。
我也试过了
git config --list | grep -oP '(?<=alias\.)\w+'
但没有成功。
编辑:
正在尝试此命令:
(git config -l | grep '^alias\.' | cut -d'=' -f1 | cut -d'.' -f2)
给了我别名列表但只给了我别名。我仍然得到相同的错误,所以我猜这里有两件事需要整理,一件与git别名列表相关,另一件与zsh相关。
转载请注明出处:http://www.yinxuebaozhuang.com/article/20230526/1194647.html