You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.7 KiB

PS1=
RPROMPT=
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_SEPARATOR=" "
ZSH_THEME_DEBLAN_USE_GIT=${ZSH_THEME_DEBLAN_USE_GIT:-1}
function deblan_precmd() {
local exit_code=$?
local datetime="%T"
local current_directory="%~"
local final_char="%%"
local is_privilegied=${(%):-%(\!.1.0)}
local prompt_width=
local prompt_content=
local term_width=
local rprompt_content=
PS1=
RPROMPT=
prompt_content="$(deblan_last_status)"
prompt_content="$prompt_content %{$fg_bold[cyan]%}${datetime}"
if [ $is_privilegied -eq 1 ]; then
prompt_content="$prompt_content %{$fg_bold[red]%}%n@%m"
final_char="%{$fg_bold[red]%}#"
else
prompt_content="$prompt_content %{$fg_bold[white]%}%n@%m"
fi
prompt_content="$prompt_content %{$fg_bold[white]%}$current_directory"
prompt_width="${#${(%):-$prompt_content}}"
term_width=$(tput cols)
if [[ "$prompt_width*1.3" -gt $term_width ]]; then
prompt_content="$prompt_content
"
else
prompt_content="$prompt_content "
fi
prompt_content="$prompt_content%{$fg_bold[yellow]%}$final_char"
prompt_content="$prompt_content %{$reset_color%}"
if [ $ZSH_THEME_DEBLAN_USE_GIT -eq 1 ]; then
if (command -v git_super_status >/dev/null); then
rprompt_content='%{$fg[$NCOLOR]%} $(git_super_status)%{$reset_color%}'
fi
fi
PS1="$prompt_content"
RPROMPT="$rprompt_content"
}
function deblan_last_status() {
local value=
if [ $exit_code -eq 0 ]; then
value="%{$fg_bold[green]%}●"
elif [ $exit_code -eq 1 ]; then
value="%{$fg_bold[red]%}●"
elif [ $exit_code -eq 130 ]; then
value="%{$fg_bold[grey]%}●"
else
value="%{$fg_bold[yellow]%}● [$exit_code]"
fi
echo -n "$value"
}
setopt prompt_subst
autoload -U add-zsh-hook
add-zsh-hook precmd deblan_precmd