Is there a way to change the command and prompt color in IRB/rails console different from their outputs?

As of now I have this in my bashrc file

PS1='${debian_chroot:+($debian_chroot)}\[\033[00;34m\]\w\[\033[00m\]\$\[\033[00;34m\] '

trap '[[ -t 1 ]] && tput sgr0' DEBUG

enter image description here

As of now, the console commands dont take the bashrc setting colors of command and prompt and it becomes tough to read when console grows bigger.

Any way to change this as well?


I suggest using pry ruby console instead of default irb, because pry has built-in syntax-coloring, indentation support. Installation is pretty simple

gem install pry

There are other tools too, which can be used with irb to enhance it's functionality. One such tool is

The other two gems installation procedure are similar. Check their github READMEs.

Here is a screenshot of the pry console.

A screenshot of pry console


Not exactly a permanent solution but makes it easy.

In IRB, instead of using puts or pp, one can use the Ruby ap

It adds color and structure to output. Really nice.

enter image description here

But I wish IRB had something built-in to handle all use cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.