linux - Can I change the input color of my bash prompt to something different than the terminal default -
my default terminal color gray, that's fine.
my bash prompt displays bunch of colors, works fine:
ps1="${color_red}\u${color_white}@${color_red}${computername} ${color_blue}\w${gitprompt} ${color_reset}"
see example: http://cl.ly/image/002f210x1f1u
but text type in, @ end of prompt, gray. want white (ansi code "[37m").
if add color_white @ end of prompt, instead of color_reset, default terminal color changes white until reset. makes weird effect of gray text, white text bleeding through @ top.
see example of problem: http://cl.ly/image/1z3g3v0e083b
how can change "input text" color of bash prompt, other terminal default color? suggestions!
i suggest changing terminal emulator's settings. appears using iterm2 (if on iterm, suggest looking @ iterm2), so:
settings -> profiles -> profile -> color. under 'basic colors' adjust 'foreground'
for changing color of input text, in zsh use a
preexec () { echo -ne "\e[0m" }
i have found hack-ish way try bash:
not natively, can hacked using debug trap. this code sets preexec ,
precmd
functions similar zsh. command line passed single argument preexec.here simplified version of code set precmd function executed before running each command.
preexec () { :; } preexec_invoke_exec () { [ -n "$comp_line" ] && return # nothing if completing local this_command=$(history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g"); preexec "$this_command" }
trap 'preexec_invoke_exec' debug trick due glyph lefkowitz; [bcat] locating original author.
Comments
Post a Comment