Thread (14 messages) flat view 14 messages, 3 authors, 2016-06-15

Re: [PATCH 2/4] git-prompt.sh: refactor colored prompt code

From: Øystein Walle <hidden>
Date: 2016-06-15 22:57:52

Eduardo R. D'Avila <erdavila <at> gmail.com> writes:
+		local c_red='\[\e[31m\]'
+		local c_green='\[\e[32m\]'
+		local c_lblue='\[\e[1;34m\]'
+		local c_clear='\[\e[0m\]'
 	fi
-	local c_red='\e[31m'
-	local c_green='\e[32m'
-	local c_lblue='\e[1;34m'
-	local c_clear='\e[0m'
I've gotten the impression it's better to use tput to generate the escape 
sequences instead of hardcoding them. So something like:

	local c_red='\['"$(tput setaf 1)"'\]'
	local c_green='\['"$(tput setaf 2)"'\]'
	local c_green='\['"$(tput setaf 4)"'\]'
	local c_clear='\['"$(tput sgr0)"'\]'

which is technically cleaner, if not visually.
 
The problem with that approach is that tput will be run several times for 
each prompt, so it would be best if the color variables were global. Another 
thing is that you rely on tput being available.

Øsse
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help