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

sh/bash/dash/ksh/zsh等Shell脚本
头像
jiyinyiyong
帖子: 631
注册时间: 2010-01-03 19:58
系统: OS X, Ubuntu(server)
来自: 杭州
联系:

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

#16

帖子 jiyinyiyong » 2011-10-30 15:14

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,,
回复