-2

I'm using iTerm 2 on Mac to login to a remote Ubuntu system. Normally iTerm 2 provides some beautiful colors when I make a connection using ssh and a key based authentication.

However, when I login using a user/password authentication I see some odd issues.

  1. The color highlighting feature is gone. ls, vim, etc everywhere it only shows in black and white. I've tried moving the Color slider to full contrast and back again but it doesn't help.

  2. Tab key no longer auto-completes. For example, if I type vim b+tab, it won't complete the filename starting with b. Instead, it inserts a tab space.

I've also tried connecting to the remote machine through ssh key (colors show up correctly, tab works) and then switching to another user via su username command. But after logging in I get the same issues again. I've searched a lot for this and I'm not finding a solution anywhere.

How can I fix this issue?

Mugen
  • 1,417
  • 5
  • 22
  • 40

2 Answers2

1

I believe, this is not an iTerm issue. In the .bashrc of the remote system, change #force_color_prompt from no to yes.

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

If this is already set and still you are facing the same problem, then the issue is that ssh does not use the bashrc file. You can use bashrc in your ssh session by adding the following to ~/.bash_profile:

if [ -f ~/.bashrc ]; then
      . ~/.bashrc
fi
j23
  • 3,139
  • 1
  • 6
  • 13
  • I tried both these options and the problem wasn't resolved. But you're right. This is a problem with bashrc / bash_profile – Mugen Feb 26 '22 at 03:58
  • The reason this doesn't work is because color_prompt tries to only change the color of the prompt (i.e., the default text that appears before you start typing). – Mugen Feb 26 '22 at 04:04
0

I finally solved this issue with the following code:

case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

And

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi
Mugen
  • 1,417
  • 5
  • 22
  • 40