diff .zsh/99.prompt.zsh @ 0:c30d68fbd368

Initial import from svn.
author Augie Fackler <durin42@gmail.com>
date Wed, 26 Nov 2008 10:56:09 -0600
parents
children
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/.zsh/99.prompt.zsh
@@ -0,0 +1,59 @@
+# Magic prompt with colors
+# username in blue if not root
+# username in red if root - time in pink w/
+# DANGER replacing the date
+# failed jobs print exit status in the RPS1 with yellow text
+setopt prompt_subst
+
+preexec () {
+	currJob="`echo $3 | cut -d ' ' -f 1 | head -n 1`"
+	if [[ "$TERM" == "screen" ]]; then
+		hostUser="%10<...<%~%<<"
+		print -Pn "\ek[$hostUser $currJob]\e\\"
+	else
+		if [[ "$FANCYTYPE" == "YES" ]]; then
+			hostUser="%n@%m: %2~"
+			print -Pn "\e]0;$hostUser [$currJob]\a"
+		fi
+	fi
+}
+
+function right_side_prompt() {
+    branch=`vcs_current_branch`
+    if [ $? = 0 ] ; then
+        echo -n $branch
+    else
+        date '+%D %H:%M'
+    fi
+}
+
+function precmd () {
+    rps_branch=`right_side_prompt`
+}
+
+if [ "x`whoami`" = "xroot" ] ; then
+	PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# '
+	if [[ "$TERM" == "screen" ]] ; then
+		PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[31m%}%n%{\e[0m%}%# '
+	fi
+	RPS1=$'%{\e[1;35m%}[DANGER %t]%{\e[0m%}%(?..%{\e[1;33m%} %?%{\e[1;0m%})'
+else
+	PS1=$'%{\e];%n@%m: %2~ [zsh]\a%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# '
+	if [[ "$TERM" == "screen" ]]; then
+		PS1=$'%{\ek[%2~ zsh]\e\\%}[%m:%3~] %{\e[34m%}%n%{\e[0m%}%# '
+	fi
+    RPS1=$'[$rps_branch]%(?..%{\e[1;33m%} %?%{\e[0m%})'
+fi
+
+if [ "$TERM" = "rxvt" ] || [ "$TERM" = "xterm" ] \
+  || [ "$TERM" = "xterm-color" ] || [ "$TERM" = "screen" ]; then
+	export FANCYTYPE="YES"
+else
+	export FANCYTYPE="NO"
+	prompt='[%m:%3~] %n%# '
+	RPS1=$'[%W %t]'
+fi
+
+#nonfancy no-frills prompt - disabled (same as the "non-fancy" one above)
+#prompt='[%m:%3~] %n%# '
+#RPS1=$'[%W %t]'