I added to my .irbrc:
IRB.conf[:PROMPT].reverse_merge!(:RAILS_ENV => {:PROMPT_I=>"#{current_app} #{rails_env} #{prompt} ", :PROMPT_N=>"#{current_app} #{rails_env} #{prompt} ", :PROMPT_S=>nil, :PROMPT_C=>"?> ", :RETURN=>"=> %s\n"})
IRB.conf[:PROMPT_MODE] = :RAILS_ENV
If I do something like:
current_app = "\e[31mfoo_bar_app\e[0m"
rails_env = "\e[32m#{RAILS_ENV}\e[0m"
then the prompt shows up beautifully colorized, but if I copy some text into my copybuffer and paste it, if I do page-up/page-down to go to the beginning/end of the current text entered, my cursor like jumps to the middle of the text for page-up, and for page-down it jumps way out to the right into an area of blank spaces where nothing had been typed, then my cursor position is totally screwed up.
Is there a way I can correct this? I would really like a colorized prompt.
I'd be willing to bet this is similar to the question I asked in Colorized output breaks linewrapping with readline
Try this:
current_app = "\001\e[31mfoo_bar_app\e[0m\002"
rails_env = "\001\e[32m#{RAILS_ENV}\e[0m\002"
Basically, your prompt is not ignoring non-printing characters which causes weird things to happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With