12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- # 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 [ $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 {
-
- binonly=(emacs mplayer lftp most more less rsu)
- args=(${=1})
- argsr=(${=2})
-
- if [[ $args[0] != $argsr[0] ]]; then
- args[0]=$argsr[0]
- fi
-
- if [[ -n ${(M)binonly:#$args[0]} ]]; then
- args=$args[0]
- fi
-
- mytitle "$args"
- }
- 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_MAGENTA%m$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
|