123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- # prompt config
- export PR_OS_NAME=$(uname -s)
- export PR_OS_ARCH=$(uname -m)
- if [ -f /etc/debian_version ]; then
- echo $PR_OS_NAME | grep -i linux >/dev/null 2>&1
- if [ $? = 0 ]; then
- PR_OS_NAME="Debian GNU/${PR_OS_NAME}"
- else
- PR_OS_NAME="Debian ${PR_OS_NAME}"
- fi
- debian_version=$(</etc/debian_version)
- [ $debian_version = 'testing/unstable' ] && PR_OS_NAME="${PR_OS_NAME} sid" || PR_OS_NAME="${PR_OS_NAME} ${debian_version}"
-
-
- if [ -f /etc/debian_chroot ]; then
- chroot_name=(${(s:-:)$(</etc/debian_chroot)})
- chroot_name=$chroot_name[0]
- PR_OS_NAME="${PR_OS_NAME} [chroot: ${chroot_name}]"
- fi
-
- fi
- [ "$TERM" = "screen" -a -n "$WINDOW" ] && PR_OS_PTY="screen/$WINDOW" || PR_OS_PTY=$(print -P %l)
- export PR_OS_PTY
- 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
-
- [[ -n ${(M)binonly:#$args[0]} ]] && args=$args[0]
-
- if [ $UID = 0 ]; then
- [ "$KONSOLE_DCOP_SESSION" ] && dcop $KONSOLE_DCOP_SESSION renameSession "*$args"
- [ "$TERM" = "screen" ] && echo -ne "\033k*$args\033\\"
- else
- [ "$KONSOLE_DCOP_SESSION" ] && dcop $KONSOLE_DCOP_SESSION renameSession "$args"
- [ "$TERM" = "screen" ] && echo -ne "\033k$args\033\\"
- fi
- }
- function precmd {
- # function called before displaying prompt
- local TERMWIDTH
- (( TERMWIDTH = ${COLUMNS} - 1 ))
- # Truncate the path if it's too long.
- local promptsize=${#${(%):---(%m)-(%n)-(%D{%H:%M})-($PR_OS_PTY)-($PR_OS_NAME)-($PR_OS_ARCH)---}}
- PR_FILLBAR="\${(l.(($TERMWIDTH - $promptsize))..${PR_HBAR}.)}"
-
- if [ $UID = 0 ]; then
- [ "$KONSOLE_DCOP_SESSION" ] && dcop $KONSOLE_DCOP_SESSION renameSession "*$(print -P %~)"
- [ "$TERM" = "screen" ] && echo -ne "\033k*$(print -P %~)\033\\"
- else
- # if running konsole, setting current directory name in tab
- [ "$KONSOLE_DCOP_SESSION" ] && dcop $KONSOLE_DCOP_SESSION renameSession "$(print -P %~)"
- # if running screen, setting current directory name in caption/statusbar
- [ "$TERM" = "screen" ] && echo -ne "\033k$(print -P %~)\033\\"
- fi
- }
- myprompt() {
- 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}]%}'
- (( count = $count + 1 ))
- done
- PR_NO_COLOUR="%{$terminfo[sgr0]%}"
-
- typeset -A altchar
- set -A altchar ${(s..)terminfo[acsc]}
- PR_SET_CHARSET="%{$terminfo[enacs]%}"
- PR_SHIFT_IN="%{$terminfo[smacs]%}"
- PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
- PR_HBAR=${altchar[q]:--}
- PR_ULCORNER=${altchar[l]:--}
- PR_LLCORNER=${altchar[m]:--}
- PR_LRCORNER=${altchar[j]:--}
- PR_URCORNER=${altchar[k]:--}
-
- if [ "$TERM" = "dumb" ]; then
- PROMPT="-(%n@%m)-(%(!.%d.%~))->"
- else
- PROMPT='\
- $PR_SET_CHARSET\
- $PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_CYAN$PR_HBAR$PR_SHIFT_OUT(\
- $PR_WHITE%m$PR_CYAN\
- $PR_SHIFT_IN$PR_CYAN)$PR_HBAR$PR_SHIFT_OUT(\
- %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