linux - Why is the super simple fuction not displaying 256 colors in my Mac terminal? -


long time mac (read gui) user started running ubuntu , has spent week or customizing .bashrc (ubuntu) file , .bash_profile (mac) informative , colorful ps1 , terminal output.

i've got tiny little function:

function colors2nums() { code in {0..255}; echo -e "\e[38;05;${code}m $code: test"; done } 

that displays 256 colors codes can choose 1 want...

it works in ubuntu (14.0.4 lts, gnome terminal) , not work @ on mac (os 10.7.5 both iterm & terminal.app).

the prompt_command function of .bashrc file on ubuntu same, copied & pasted line-for-line mac's prompt_command function in .bash_profile.

both ps1 prompts identical in color (with odd spacing on mac side) , ls -gfa (or variant) prints in colors set ls_colors , .dircolors. colors working output, not all. on mac, 256 lines in same color terminal input set last escaped color (green, white, whatever) in ps1.

wth?!?

and yes, i've tried 2 variations of trap - debug (hack?):

#trap 'echo -ne \e[0m' debug  trap 'printf "\e[0m" "$_"' debug 

that works reset output on ubuntu side of things. neither works on mac.

what missing?

try using printf instead:

for code in {0..255}; printf "\e[38;05;${code}m $code: test"; done 

enter image description here


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -