/etc/zsh/zshrc: re-enable smiley, allow manual overriding of RPROMPT
authorMichael Prokop <mika@grml.org>
Sat, 21 Apr 2007 21:58:54 +0000 (23:58 +0200)
committerMichael Prokop <mika@grml.org>
Sat, 21 Apr 2007 21:58:54 +0000 (23:58 +0200)
debian/changelog
etc/zsh/zshrc

index 66d5507..d0a5ad8 100644 (file)
@@ -1,3 +1,12 @@
+grml-etc-core (0.2.48) unstable; urgency=low
+
+  * /etc/zsh/zshrc:
+    - re-enable smiley in RPROMPT, thanks to transient_rprompt
+      [thanks for the pointer, Christian Schneider!]
+    - allow manual overriding of RPROMPT
+
+ -- Michael Prokop <mika@grml.org>  Sat, 21 Apr 2007 23:57:28 +0200
+
 grml-etc-core (0.2.47) unstable; urgency=low
 
   * Big rewrite of /etc/zsh/completion.d/, thanks to ft!
index 018914c..755b599 100644 (file)
@@ -3,7 +3,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Son Apr 15 22:36:24 CEST 2007 [mika]
+# Latest change: Sam Apr 21 23:57:20 CEST 2007 [mika]
 ################################################################################
 # This file is sourced only for interactive shells. It
 # should contain commands to set up aliases, functions,
@@ -443,17 +443,20 @@ fi
 
   # precmd () { setopt promptsubst; [[ -o interactive ]] && jobs -l;
 
+  setopt transient_rprompt # make sure to use right prompt only when not running a command
   is4 && [[ -z $NOPRECMD ]] && precmd () {
       [[ -n $NOPRECMD ]] && return 0
+      # allow manual overwriting of RPROMPT
+      [[ -n $RPROMPT ]] && echo -n $'\ekzsh\e\\' && return 0
       # just use DONTSETRPROMPT=1 to be able to overwrite RPROMPT
-      if [[ -z ${DONTSETRPROMPT} ]] ; then
-        if [ -n "$BATTERY" ] ; then
-          # RPROMPT="%(?..:()% ${PERCENT}${SCREENTITLE}"
-          RPROMPT="${PERCENT}${SCREENTITLE}"
-        else
-          # RPROMPT="%(?..:()% ${SCREENTITLE}"
-          RPROMPT="${SCREENTITLE}"
-        fi
+      if [[ -z $DONTSETRPROMPT ]] ; then
+         if [[ -n $BATTERY ]] ; then
+            RPROMPT="%(?..:()% ${PERCENT}${SCREENTITLE}"
+            # RPROMPT="${PERCENT}${SCREENTITLE}"
+         else
+            RPROMPT="%(?..:()% ${SCREENTITLE}"
+            # RPROMPT="${SCREENTITLE}"
+         fi
       fi
       # adjust title of xterm
       # see http://www.faqs.org/docs/Linux-mini/Xterm-Title.html
@@ -476,15 +479,15 @@ fi
   # get the name of the program currently running and hostname of local machine
   # set screen window title if running in a screen
       if [[ "$TERM" == screen* ]]; then
-          # local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]}       # dont't use hostname
-          local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}$NAME" # use hostname
-          echo -ne "\ek$CMD\e\\"
+         # local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]}       # dont't use hostname
+         local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}$NAME" # use hostname
+         echo -ne "\ek$CMD\e\\"
       fi
   # set the screen title to "zsh" when sitting at the command prompt:
       if [[ "$TERM" == screen* ]]; then
-           SCREENTITLE=$'%{\ekzsh\e\\%}'
+         SCREENTITLE=$'%{\ekzsh\e\\%}'
       else
-           SCREENTITLE=''
+         SCREENTITLE=''
       fi
   # adjust title of xterm
       case $TERM in (xterm*|rxvt)
@@ -522,11 +525,11 @@ fi
 
   # don't use colors on dumb terminals (like emacs):
   if [[ "$TERM" == dumb ]] ; then
-    PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< %# "
+     PROMPT="${EXITCODE}${debian_chroot:+($debian_chroot)}%n@%m %40<...<%B%~%b%<< %# "
   else
     # only if $GRMLPROMPT is set (e.g. via 'GRMLPROMPT=1 zsh') use the extended prompt
     # set variable identifying the chroot you work in (used in the prompt below)
-    if [[ -n "$GRMLPROMPT" ]]; then
+    if [[ -n $GRMLPROMPT ]]; then
       PROMPT="${RED}${EXITCODE}${CYAN}[%j running job(s)] ${GREEN}{history#%!} ${RED}%(3L.+.) ${BLUE}%* %D
 ${BLUE}%n${NO_COLOUR}@%m %40<...<%B%~%b%<< %# "
     else