碎碎碎碎屁

Archive for 四月, 2012

$PS1增加py的virtualenv支持

by on 4月.09, 2012, under ,

刚刚开始学用python的virtualenv,顺带用上了virtualenv wrapper,发现默认会在PS1之前加上($VIRTUAL_ENV),不好看啊,和我原来的不匹配。然后就花了几小时去改之前就写的很头大的PS1。现在显示到右边啦~

新版PS1效果图

PS1='${debian_chroot:+($debian_chroot)}`a=$?;if [ $a -ne 0 ]; then a=" "$a; echo -ne "\[\e[s\e[1A\e[$((COLUMNS-2))G\e[32m\e[1;41m${a:(-3)}\e[u\]\[\e[0m\e[2m\]"; fi`\[\033[01;32m\]\u@\[\033[01;35m\]\h\[\033[00m\]:\[\033[01;34m\]`pwd`\[\033[00m\]`B=$(git branch 2>/dev/null | sed -e "/^ /d" -e "s/* \(.*\)/\1/"); if [ "$B" != "" ]; then S="git"; elif [ -e .bzr ]; then S=bzr; elif [ -e .hg ]; then S="hg";B="$(hg branch)"; elif [ -e .svn ]; then S="svn"; else S=""; fi; W="\`showvirtualenv 2>/dev/null \`"; if [ "$W" != "" ]; then if [ "${W:0:14}" = "showvirtualenv" ]; then W=""; else W="workon:$W"; fi; fi; if [ "$S" != "" ]; then if [ "$B" != "" ]; then M=$S:$B; else M=$S; fi; fi; if [ "$W" != "" ]; then if [ "$M" = "" ]; then M=$W; else M="$W $M"; fi; fi; [[ "$M" != "" ]] && echo -en "\e[s\e[$((COLUMNS-${#M}-1))G\e[33m\e[1;40m($M)\e[0m\e[u"`\n\[\033[01;34m\]\$\[\033[00m\] '
不分割了,太损血了。

Leave a Comment :, , , more...