碎碎碎碎屁

Tag: github

记录下自己的$PS1

by on 10月.07, 2011, under ,

Steve Jobs, 1955 – 2011

今天又在弄$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; if [ "$S" != "" ]; then if [ "$B" != "" ]; then M=$S:$B; else M=$S; 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\] '
这个也可以从我github里找bashrc的
效果图如下
$PS1的效果图
有以下一些特性:分两排显示,前一排最后会显示错误$?,第一排地址显示绝对路径,第一排结尾显示版本控制的信息 (continue reading…)

5 Comments :, , more...