shell – 使用运算符j处理zsh数组
发布时间:2020-12-15 22:24:09 所属栏目:安全 来源:网络整理
导读:以下代码取自 here: function +vi-git-st() { local ahead behind remote local -a gitstatus # Are we on a remote-tracking branch? remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2/dev/null)/refs/remote
以下代码取自
here:
function +vi-git-st() { local ahead behind remote local -a gitstatus # Are we on a remote-tracking branch? remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs/remotes/} if [[ -n ${remote} ]] ; then # for git prior to 1.7 # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l) ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) (( $ahead )) && gitstatus+=( "${c3}+${ahead}${c2}" ) # for git prior to 1.7 # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l) behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) (( $behind )) && gitstatus+=( "${c4}-${behind}${c2}" ) hook_com[branch]="${hook_com[branch]} [${remote} ${(j:/:)gitstatus}]" fi } 我不明白最后一行.变量gitstatus是一个数组,那么${(j:/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |