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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2013/6/22 Øystein Walle <oystwa@xxxxxxxxx>:
> 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.

Are there any guidelines regarding global shell script variables?

I'm considering doing this:
   __git_c_red="\[$(tput setaf 1 || echo -e '\e[31m')\]"
which handles the case where tput is not available.


Eduardo
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]