1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #
- # Prompt config
- #
- setopt prompt_subst
- # enable colors
- autoload colors zsh/terminfo
- if [[ "$terminfo[colors]" -ge 8 ]]; then
- colors
- fi
- for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
- eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
- eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
- done
- PR_NO_COLOR="%{$terminfo[sgr0]%}"
- export PR_OS_NAME=$(uname -s)
- export PR_OS_ARCH=$(uname -m)
- if [ -f /etc/debian_version ]; then
- PR_OS_NAME="$(lsb_release -is)/$(lsb_release -cs)"
- if [ -f /etc/debian_chroot ]; then
- PR_OS_NAME="${PR_LIGHT_RED}chroot:${PR_WHITE}${PR_OS_NAME}"
- fi
- fi
- PR_OS_NAME="${PR_OS_NAME} ${PR_OS_ARCH}"
- if [ -n "$SSH_CLIENT" ]; then
- export PR_OS_SSH="${PR_LIGHT_RED}ssh:"
- else
- export PR_OS_SSH=
- fi
- if [ "$UID" = 0 ]; then
- export PR_ROOT_PREFIX='*'
- else
- export PR_ROOT_PREFIX=
- fi
- function mytitle {
- # if running 'xterm like' terminal setting directory name in title bar
- if [ "$TERM" = "xterm" ]; then
- echo -ne "\033]0;${PR_ROOT_PREFIX}${1}\007"
- fi
- }
- function preexec {
- local -a buffer
- buffer=(${=1})
- mytitle "$buffer[1]"
- }
- function precmd {
- mytitle "$(print -P %~)"
- }
- myprompt() {
- if [ "$TERM" = "dumb" ]; then
- PROMPT="-(%n@%m)-(%(!.%d.%~))->"
- else
- PROMPT='\
- ${PR_BLUE}\
- %1(j.-(${PR_YELLOW}jobs:${PR_WHITE}%j${PR_BLUE}).)\
- ${PR_BLUE}-(\
- %(!.${PR_RED}%n.${PR_LIGHT_GREEN}%n)\
- ${PR_WHITE}@${PR_OS_SSH}${PR_MAGENTA}%m${PR_WHITE} ${PR_OS_PTY}${PR_BLUE})-(\
- ${PR_WHITE}${PR_OS_NAME}${PR_BLUE})-(${PR_WHITE}%(!.%d.%~)${PR_BLUE})
- %0(?..${PR_RED}ret:${PR_WHITE}%?${PR_BLUE})>${PR_NO_COLOR}'
- fi
- }
- myprompt
|