1
0

rename remaining remnants

This commit is contained in:
Konstantin Demin 2021-03-21 22:32:39 +03:00
parent eeaa54993a
commit 87d9c7f978
Signed by: krd
GPG Key ID: 1F33CB0BA4731BC6

View File

@ -4,28 +4,28 @@
typeset -gA ZSHU_PS typeset -gA ZSHU_PS
ZSHU_PS[git]=0 ZSHU_PS[git]=0
_zshu_git_avail() { (( $+commands[git] )) ; } __z_git_avail() { (( $+commands[git] )) ; }
_zshu_git() { GIT_OPTIONAL_LOCKS=0 command git "$@"; } __z_git() { GIT_OPTIONAL_LOCKS=0 command git "$@"; }
_zshu_git_is_repo() { _zshu_git rev-parse --git-dir &>/dev/null ; } __z_git_is_repo() { __z_git rev-parse --git-dir &>/dev/null ; }
zshu-git-test() { z-git-test() {
[ "${ZSHU_PS[git]}" = '1' ] || return 1 [ "${ZSHU_PS[git]}" = '1' ] || return 1
_zshu_git_avail || return 2 __z_git_avail || return 2
_zshu_git_is_repo || return 3 __z_git_is_repo || return 3
return 0 return 0
} }
_zshu_git_pwd() { __z_git_pwd() {
zshu-git-test || return z-git-test || return
local p=${(%):-%~} local p=${(%):-%~}
[[ "$p" =~ '/.+' ]] || return [[ "$p" =~ '/.+' ]] || return
local s pfx last local s pfx last
s=$(_zshu_git rev-parse --show-prefix) s=$(__z_git rev-parse --show-prefix)
s="${s%%/}" s="${s%%/}"
if [ -n "$s" ] ; then if [ -n "$s" ] ; then
p=${p%%/$s} p=${p%%/$s}
@ -39,16 +39,16 @@ _zshu_git_pwd() {
ZSHU_PS[pwd]="%F{magenta}$p%F{cyan}${pfx}%B${last}%f%b" ZSHU_PS[pwd]="%F{magenta}$p%F{cyan}${pfx}%B${last}%f%b"
} }
zshu-git-enable() { ZSHU_PS[git]=1 ; } z-git-enable() { ZSHU_PS[git]=1 ; }
zshu-git-disable() { ZSHU_PS[git]=0 ; } z-git-disable() { ZSHU_PS[git]=0 ; }
zshu-git-status() { z-git-status() {
_zshu_git_avail __z_git_avail
echo "Git binary: "${(%):-%(?..NOT )}"found in PATH" echo "Git binary: "${(%):-%(?..NOT )}"found in PATH"
[ "${ZSHU_PS[git]}" = 1 ] [ "${ZSHU_PS[git]}" = 1 ]
echo "Git prompt: "${(%):-%(?.enabled.disabled)} echo "Git prompt: "${(%):-%(?.enabled.disabled)}
_zshu_git_is_repo __z_git_is_repo
echo "Git repo: "${(%):-%(?..NOT )}"present" echo "Git repo: "${(%):-%(?..NOT )}"present"
} }
ZSHU[pwd_hook]="${ZSHU[pwd_hook]}${ZSHU[pwd_hook]:+ }_zshu_git_pwd" ZSHU[pwd_hook]="${ZSHU[pwd_hook]}${ZSHU[pwd_hook]:+ }__z_git_pwd"