configs  Check-in [1cacfaf154]

Overview
Comment:zshrc: Better way to set colors
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1cacfaf154179237da6f18387c08eecbf1e9c06873acea8113b84ab7155240cd
User & Date: js 2020-02-15 15:23:53
Context
2020-02-15
15:45
zshrc: Add an option to get the old simple prompt check-in: a3bceca4d2 user: js tags: trunk
15:23
zshrc: Better way to set colors check-in: 1cacfaf154 user: js tags: trunk
15:07
zshrc: Fix a typo check-in: 98d3196205 user: js tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to zshrc.

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
		}
		;;
	*)
		__update_terminal_cwd() {}
		;;
esac

__color() { print "%{\e[$1m%}" }
__color_256() { __color "38;5;$1" }
__reset_color() { __color 0 }

set_prompt() {
	PS1="$(__color_256 23)%m "
	PS1+="$(__color_256 29)%c"
	PS1+="$@$(__color_256 36)%B%(!.#.>)$(__reset_color) "
	PS2="%B>%b "
	RPS1="%(1j.$(__color "1;33")%j$(__reset_color).)"
	RPS1+="%(?..%(1j. .)$(__color "1;31")%?$(__reset_color))"
	RPS2="%(1_.$(__color "1;30")(%_%)$(__reset_color).)"
}
set_prompt

__precmd() {
	__update_terminal_cwd

	local branch_name=$(git symbolic-ref HEAD 2>/dev/null)
	branch_name=${branch_name##refs/heads/}
	if [ -n "$branch_name" -a "$branch_name" != master ]; then
		local branch="$(__color_256 36)($(__color_256 78)$branch_name"
		branch+="$(__color_256 36))"
	fi
	set_prompt $branch
}

case $TERM in
	aterm|Eterm|rxvt*|uxterm*|xterm*)
		# Use set_title if you want to change the term title
		set_title() {
			# Without this, precmd would override it
			precmd() { __precmd }
			print -Pn "\e]0;$@\a"
		}

		unset_title() {
			precmd() {
				print -Pn "\e]0;%m:%c\a"
				__precmd
			}
		}

		unset_title
		;;
	*)
		precmd() { __precmd }
		;;
esac








<
<
<
<

<
<
|

|
<
|









|
<



















<







63
64
65
66
67
68
69




70


71
72
73

74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
		}
		;;
	*)
		__update_terminal_cwd() {}
		;;
esac





set_prompt() {


	PS1="%F{23}%m %F{29}%c$1%F{36}%(!.#.>)%f "
	PS2="%B>%b "
	RPS1="%(1j.%F{yellow}%j%f.)%(?..%(1j. .)%F{red}%?%f)"

	RPS2="%(1_.%F{black}%B(%_%)%b%f.)"
}
set_prompt

__precmd() {
	__update_terminal_cwd

	local branch_name=$(git symbolic-ref HEAD 2>/dev/null)
	branch_name=${branch_name##refs/heads/}
	if [ -n "$branch_name" -a "$branch_name" != master ]; then
		local branch="%F{36}(%F{78}$branch_name%F{36})"

	fi
	set_prompt $branch
}

case $TERM in
	aterm|Eterm|rxvt*|uxterm*|xterm*)
		# Use set_title if you want to change the term title
		set_title() {
			# Without this, precmd would override it
			precmd() { __precmd }
			print -Pn "\e]0;$@\a"
		}

		unset_title() {
			precmd() {
				print -Pn "\e]0;%m:%c\a"
				__precmd
			}
		}

		unset_title
		;;
	*)
		precmd() { __precmd }
		;;
esac