分页: 2 / 2

Re: 大家自定义以后的 PS1 都是什么样的?

发表于 : 2011-10-30 15:14
jiyinyiyong
cjxgm 写了:某的比较复杂

代码: 全选

git_parse_branch()
{
	git branch 2> /dev/null | awk '/\*.*/{print "[" $2 "]"}'
}

ind_cwd()
{
	GB="$(git_parse_branch)"
	if [ -z "$GB" ]; then
		echo "$1"
	else
		echo "($2)"
	fi
}

export PS1='\[\e[1;32m\]\u@\h \[\e[1;35m\]$(git_parse_branch)\[\e[1;33m\]$(ind_cwd "\w" "\W")\[\e[0m\]\$ '
见识了, mark 之, 等以后去 git 开发了再 copy,,