juanpazos
juanpazos

Reputation: 157

iTerm2: Differentiate user input from computer output for better readability

When using iTerm, it gets confusing to understand what happened in previous commands, cause user input has the same formatting as the info output.

Is it possible to do something as below?

This is how it is today:

enter image description here

This is a simple solution that would make my life easier:

enter image description here

Upvotes: 1

Views: 702

Answers (1)

Code Different
Code Different

Reputation: 93181

You can customize your PS1 variable in ~/.bash_profile file. For example, this is mine:

export PS1='\[\e[32;1m\]\h:\[\e[31m\]\W \[\e[32;1m\]\u\[\e[0m\]\$ '

The tokens are:

\e[32;1m\]  - the color green
\h          - host name (i.e. the computer's name)
:           - the literal colon (:) character
\e[31m\]    - the color red
\W          - current working directory
\u          - user name
\e[0m\]     - the color black
\$          - normally display the dollar sign, change to # when logged in as root

Reference. Google for "ps1 prompt generator" for tools to help you configure it. This is what my prompt looks like:

enter image description here

Upvotes: 2

Related Questions