ZSH: Updated prompt
This commit is contained in:
parent
e779175de5
commit
a0209264b5
@ -11,12 +11,44 @@ p_host='%F{blue}%m%f'
|
|||||||
## Print path in yellow
|
## Print path in yellow
|
||||||
p_path='%F{yellow}%~%f'
|
p_path='%F{yellow}%~%f'
|
||||||
## Print prompt sign in red if the previous command retunend and error, otherwise print it in white
|
## Print prompt sign in red if the previous command retunend and error, otherwise print it in white
|
||||||
p_pr='%(?.%F{white}.%F{red}) %B〉%b%f'
|
p_pr='%(?.%F{magenta}.%F{red})%B〉%b%f%'
|
||||||
|
|
||||||
# Add green arrows (⇣⇡) if connection is via ssh
|
# Add green arrows (⇣⇡) if connection is via ssh
|
||||||
if [[ "${SSH_CONNECTION}" ]]; then
|
if [[ "${SSH_CONNECTION}" ]]; then
|
||||||
p_ssh=" %F{green}⇣⇡%f";
|
p_ssh=" %F{green}⇣⇡%f";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
PS1="$p_user$p_at$p_host$p_ssh $p_path$p_pr"
|
# Transient prompt based on https://github.com/romkatv/powerlevel10k/issues/888#issuecomment-657969840
|
||||||
unset p_at p_user p_host p_path p_pr
|
zle-line-init() {
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
[[ $CONTEXT == start ]] || return 0
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
zle .recursive-edit
|
||||||
|
local -i ret=$?
|
||||||
|
[[ $ret == 0 && $KEYS == $'\4' ]] || break
|
||||||
|
[[ -o ignore_eof ]] || exit 0
|
||||||
|
done
|
||||||
|
|
||||||
|
local saved_prompt=$PROMPT
|
||||||
|
local saved_rprompt=$RPROMPT
|
||||||
|
PROMPT='${nl}$p_pr '
|
||||||
|
RPROMPT=''
|
||||||
|
zle .reset-prompt
|
||||||
|
PROMPT=$saved_prompt
|
||||||
|
RPROMPT=$saved_rprompt
|
||||||
|
|
||||||
|
if (( ret )); then
|
||||||
|
zle .send-break
|
||||||
|
else
|
||||||
|
zle .accept-line
|
||||||
|
fi
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N zle-line-init
|
||||||
|
|
||||||
|
nl=$'\n'
|
||||||
|
PS1="${nl}$p_user$p_at$p_host$p_ssh $p_path${nl}$p_pr"
|
||||||
|
#unset p_at p_user p_host p_path p_pr
|
Loading…
Reference in New Issue
Block a user