123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- # 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_COLOUR="%{$terminfo[sgr0]%}"
- export PR_OS_NAME=$(uname -s)
- export PR_OS_ARCH=$(uname -m)
- if [ -f /etc/debian_version ]; then
- if [ "$PR_OS_NAME" = "Linux" ]; then
- PR_OS_NAME="debian $(</etc/debian_version)"
- else
- PR_OS_NAME="debian/${PR_OS_NAME} $(</etc/debian_version)"
- fi
- if [ -f /etc/debian_chroot ]; then
- PR_OS_NAME="${PR_OS_NAME} ${PR_LIGHT_RED}chroot:${PR_WHITE}$(</etc/debian_version)"
- fi
- fi
- PR_OS_NAME="${PR_OS_NAME} ${PR_OS_ARCH}"
- if [ "$TERM" = "screen" -a -n "$WINDOW" ]; then
- export PR_OS_PTY="scr/$WINDOW"
- else
- export PR_OS_PTY=$(print -P %l)
- fi
- 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 konsole, setting current directory name in tab
- [ "$KONSOLE_DCOP_SESSION" ] && dcop $KONSOLE_DCOP_SESSION renameSession "${PR_ROOT_PREFIX}${1}"
- # if running screen, setting current directory name in caption/statusbar
- [ "$TERM" = "screen" ] && echo -ne "\033k${PR_ROOT_PREFIX}${1}\033\\"
- # if running 'xterm like' terminal setting directory name in title bar
- [ "$TERM" = "xterm" ] && echo -ne "\033]0;${PR_ROOT_PREFIX}${1}\007"
- }
- 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_COLOUR}'
- fi
- }
- myprompt
|