0

I am a new user of tmux and wondering how I can highlight machine name and working directory? What I mean is below.

In default Ubuntu terminal:

Default terminal

While in tmux:

tmux

I know this is a minor, but having these highlighted is very helpful for reading.

1
  • (1) Is the shell in question Bash? What is the output of echo "$0"? (2) What is the output of echo "$TERM"? Apr 12 at 4:19

1 Answer 1

1

I assume the shell is Bash.

In Ubuntu the skeletal (default) .bashrc contains this or similar snippet:

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

Later in the file PS1 is set according to the value of $color_prompt and you get a prompt that is colored or not.

Your ~/.bashrc started as a copy of the skeletal one and it still contains the snippet (unless you edited it out; but you probably didn't).

Most likely in tmux your $TERM is tmux or tmux-256color. tmux-256color would be detected by the snippet and there would be no problem, so apparently in your case the value is tmux (verify with echo "$TERM" in a shell inside tmux).

To enable colored prompt when $TERM expands to tmux, edit your ~/.bashrc, locate the snippet and change the relevant line to:

    tmux|screen|xterm-color|*-256color) color_prompt=yes;;

(I included screen to solve the same problem for GNU Screen in advance, in case you ever use it.)

Existing shells will not be magically fixed, but prompts in new shells (e.g. in newly created tmux panes) will be colored.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .