Rebuild PROMPT with new fanciness
This commit is contained in:
parent
fcf0673722
commit
70d8f0b9d4
1 changed files with 23 additions and 30 deletions
53
zshrc
53
zshrc
|
@ -19,16 +19,16 @@ print_info_noisy 1 "Initializing interactive Z Shell"
|
||||||
autoload is-at-least
|
autoload is-at-least
|
||||||
if (is-at-least '4.3.7'); then
|
if (is-at-least '4.3.7'); then
|
||||||
bgjob="%(1j.%B%F{magenta}* %F{default}%b.)"
|
bgjob="%(1j.%B%F{magenta}* %F{default}%b.)"
|
||||||
hist="%(0?.%h.%B%F{red}%h%F{default}%b)"
|
cmdstat="%(0?..%B%F{red}! %F{default}%b)"
|
||||||
isroot="%(!.%B%F{red}%#%F{default}%b.%#)"
|
isroot="%(!.%B%F{red}%#%F{default}%b.%#)"
|
||||||
else
|
else
|
||||||
bgjob="%(1j.%{$fg_bold[magenta]%}* %{$reset_color%}.)"
|
bgjob="%(1j.%{$fg_bold[magenta]%}* %{$reset_color%}.)"
|
||||||
hist="%(0?.%h.%{$fg_bold[red]%}%h%{$reset_color%})"
|
cmdstat="%(0?.%h.%{$fg_bold[red]%}%h%{$reset_color%})"
|
||||||
isroot="%(!.%{$fg_bold[red]%}%#%{$reset_color%}.%#)"
|
isroot="%(!.%{$fg_bold[red]%}%#%{$reset_color%}.%#)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_info_sub_noisy 2 'Setting prompt'
|
print_info_sub_noisy 2 'Setting prompt'
|
||||||
PROMPT=" $hist $bgjob$isroot "
|
PROMPT_LINE="$cmdstat$bgjob$isroot "
|
||||||
|
|
||||||
|
|
||||||
precmd_xterm_title()
|
precmd_xterm_title()
|
||||||
|
@ -37,46 +37,34 @@ precmd_xterm_title()
|
||||||
[ -n $DISPLAY ] && print -Pn "\e]2;%n@%m\a"
|
[ -n $DISPLAY ] && print -Pn "\e]2;%n@%m\a"
|
||||||
}
|
}
|
||||||
|
|
||||||
precmd_separator()
|
precmd_info()
|
||||||
{
|
{
|
||||||
# time divider
|
PROMPT_NAME='%B%F{magenta}%n%f%b'
|
||||||
local fillnum=$COLUMNS
|
PROMPT_HOST='%B%F{red}%m%f%b'
|
||||||
local sep=''
|
PROMPT_CWD='%B%F{green}%~%f%b'
|
||||||
for (( i=0; $i < $fillnum; i++)); do sep="-$sep"; done
|
|
||||||
print -P "%B%F{black}$sep"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
precmd_separator_info()
|
precmd_git_prompt()
|
||||||
{
|
|
||||||
pstr=''
|
|
||||||
if [ ! -z "$SSH_CONNECTION" ]; then
|
|
||||||
pstr+=`print -P "\-\-\( %n@%m \)"`
|
|
||||||
fi
|
|
||||||
pstr+=`print -P "\-\-\( %~ \)"`
|
|
||||||
time=`print -P "\( %T \)\-\-"`
|
|
||||||
filler=$(($COLUMNS - ${#pstr} - ${#time}))
|
|
||||||
for (( i=0; $i < $filler; i++)); do
|
|
||||||
pstr="${pstr}-"
|
|
||||||
done
|
|
||||||
print -P "%K{black}$pstr$time%k"
|
|
||||||
}
|
|
||||||
|
|
||||||
precmd_git_rprompt()
|
|
||||||
{
|
{
|
||||||
#local gstat=`git status 2>/dev/null`
|
#local gstat=`git status 2>/dev/null`
|
||||||
local branch=`git branch 2>/dev/null | grep '^\*' | cut -d' ' -f2`
|
local branch=`git branch 2>/dev/null | grep '^\*' | cut -d' ' -f2`
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
RPROMPT=''
|
PROMPT_REPO="%B%F{cyan}$branch%f%b"
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
RPROMPT="%F{yellow}$branch%f"
|
|
||||||
#echo $gstat | grep '^nothing' 1>/dev/null 2>&1
|
#echo $gstat | grep '^nothing' 1>/dev/null 2>&1
|
||||||
#if [[ $? != 0 ]]; then
|
#if [[ $? != 0 ]]; then
|
||||||
# RPROMPT="%B%F{red}*%f%b$RPROMPT"
|
# RPROMPT="%B%F{red}*%f%b$RPROMPT"
|
||||||
#fi
|
#fi
|
||||||
}
|
}
|
||||||
|
|
||||||
precmd_functions=(precmd_xterm_title precmd_separator_info precmd_git_rprompt)
|
precmd_assemble_prompt()
|
||||||
|
{
|
||||||
|
PROMPT="
|
||||||
|
$PROMPT_NAME on $PROMPT_HOST at $PROMPT_CWD on $PROMPT_REPO
|
||||||
|
$PROMPT_LINE"
|
||||||
|
}
|
||||||
|
|
||||||
|
precmd_functions=(precmd_xterm_title precmd_info precmd_git_prompt)
|
||||||
|
|
||||||
print_info_sub_noisy 2 'Setting options'
|
print_info_sub_noisy 2 'Setting options'
|
||||||
# Shell options
|
# Shell options
|
||||||
|
@ -200,3 +188,8 @@ if [ -e $HOME/.zshrc.local ]; then
|
||||||
print_info_noisy 3 "Sourcing local Z Shell settings"
|
print_info_noisy 3 "Sourcing local Z Shell settings"
|
||||||
source $HOME/.zshrc.local
|
source $HOME/.zshrc.local
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Put this down here 'cause some of the local stuff might modify the prompt or
|
||||||
|
# add functions to $precmd_functions. Doing this here ensures it's always the
|
||||||
|
# last function to be executed before the prompt is displayed.
|
||||||
|
precmd_functions+=(precmd_assemble_prompt)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue