|
@@ -1,24 +1,58 @@
|
|
|
|
|
|
# prompt config
|
|
# 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_NAME=$(uname -s)
|
|
export PR_OS_ARCH=$(uname -m)
|
|
export PR_OS_ARCH=$(uname -m)
|
|
|
|
|
|
if [ -f /etc/debian_version ]; then
|
|
if [ -f /etc/debian_version ]; then
|
|
- PR_OS_NAME="Debian GNU/${PR_OS_NAME} $(</etc/debian_version)"
|
|
|
|
|
|
+ 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}"
|
|
|
|
|
|
- [ -f /etc/debian_chroot ]\
|
|
|
|
- && PR_OS_NAME="$PR_OS_NAME [chroot: $(</etc/debian_version)]"
|
|
|
|
-
|
|
|
|
|
|
+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
|
|
fi
|
|
|
|
|
|
-[ "$TERM" = "screen" -a -n "$WINDOW" ] && PR_OS_PTY="screen/$WINDOW" || PR_OS_PTY=$(print -P %l)
|
|
|
|
-export PR_OS_PTY
|
|
|
|
|
|
+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 {
|
|
function preexec {
|
|
|
|
|
|
- binonly=(emacs mplayer lftp most more less rsu)
|
|
|
|
-
|
|
|
|
|
|
+ binonly=(emacs mplayer lftp most more less rsu)
|
|
args=(${=1})
|
|
args=(${=1})
|
|
argsr=(${=2})
|
|
argsr=(${=2})
|
|
|
|
|
|
@@ -26,92 +60,32 @@ function preexec {
|
|
args[0]=$argsr[0]
|
|
args[0]=$argsr[0]
|
|
fi
|
|
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\\"
|
|
|
|
|
|
+ if [[ -n ${(M)binonly:#$args[0]} ]]; then
|
|
|
|
+ args=$args[0]
|
|
fi
|
|
fi
|
|
|
|
+
|
|
|
|
+ mytitle "$args"
|
|
}
|
|
}
|
|
|
|
|
|
function precmd {
|
|
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
|
|
|
|
|
|
+ mytitle "$(print -P %~)"
|
|
}
|
|
}
|
|
|
|
|
|
-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]:--}
|
|
|
|
-
|
|
|
|
|
|
+myprompt() {
|
|
if [ "$TERM" = "dumb" ]; then
|
|
if [ "$TERM" = "dumb" ]; then
|
|
PROMPT="-(%n@%m)-(%(!.%d.%~))->"
|
|
PROMPT="-(%n@%m)-(%(!.%d.%~))->"
|
|
else
|
|
else
|
|
PROMPT='\
|
|
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(\
|
|
|
|
|
|
+$PR_BLUE\
|
|
|
|
+%1(j.-(${PR_YELLOW}jobs:$PR_WHITE%j$PR_BLUE).)\
|
|
|
|
+$PR_BLUE-(\
|
|
%(!.$PR_RED%n.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