Quellcode durchsuchen

Improve and clean zsh prompt.

Emmanuel Bouthenot vor 16 Jahren
Ursprung
Commit
a1fb830c5e
1 geänderte Dateien mit 17 neuen und 24 gelöschten Zeilen
  1. 17 24
      .zsh.d/config.d/prompt.zsh

+ 17 - 24
.zsh.d/config.d/prompt.zsh

@@ -24,7 +24,7 @@ if [ -f /etc/debian_version ]; then
 	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)"
+	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}"
@@ -35,6 +35,12 @@ 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
@@ -51,20 +57,9 @@ function mytitle {
 }
 
 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"
+    local -a buffer
+    buffer=(${=1})
+    mytitle "$buffer[1]"
 }
 
 function precmd {
@@ -76,15 +71,13 @@ myprompt() {
 	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'
+${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
 }