Created
June 25, 2009 18:10
-
-
Save optixx/136034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# Prompt | |
############################################################################### | |
BLACK="%{[0m%}" | |
BOLD_BLACK="%{[1;30m%}" | |
RED="%{[0;31m%}" | |
BOLD_RED="%{[1;31m%}" | |
GREEN="%{[0;32m%}" | |
BOLD_GREEN="%{[1;32m%}" | |
YELLOW="%{[0;33m%}" | |
BOLD_YELLOW="%{[1;33m%}" | |
BLUE="%{[0;34m%}" | |
BOLD_BLUE="%{[1;34m%}" | |
MAUVE="%{[0;35m%}" | |
BOLD_MAUVE="%{[1;35m%}" | |
CYAN="%{[0;36m%}" | |
BOLD_CYAN="%{[1;36m%}" | |
WHITE="%{[0;37m%}" | |
DEFAULT="%{[0;39m%}" | |
# set shell title | |
function title() { | |
# escape '%' chars in $1, make nonprintables visible | |
a=${(V)1//\%/\%\%} | |
# Truncate command, and join lines. | |
a=$(print -Pn "%40>...>$a" | tr -d "\n") | |
case $TERM in | |
screen) | |
print -Pn "\ek$a:$3\e\\" # screen title (in ^A") | |
;; | |
xterm*|rxvt) | |
print -Pn "\e]2;$2 | $a:$3\a" # plain xterm title | |
;; | |
esac | |
} | |
function issucceed { | |
if [ "$1" -eq 0 ]; then | |
HIST_COLOR="$BOLD_RED" | |
PREFIX="" | |
else | |
HIST_COLOR="$BOLD_BLACK" | |
PREFIX="[$BOLD_RED${1}$BLACK]" | |
fi | |
} | |
function precmd { | |
issucceed "$?" | |
PS1="${PREFIX}[$BOLD_BLUE%n$BLACK@$BOLD_GREEN%m$BLACK]$BOLD_MAUVE%3c $DEFAULT%# " | |
RPS1="[$HIST_COLOR%!$BLACK]" | |
test -z $SUDO_USER || PS1="${PREFIX}[$BOLD_RED%n$BLACK@$BOLD_RED%m$BLACK]$BOLD_MAUVE%3c $DEFAULT%# " | |
title "zsh" "$USER@%m" "%25<...<%~" | |
} | |
## preexec is called just before any command line is executed | |
function preexec() { | |
title "$1" "$USER@%m" "%25<...<%~" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment