Search code examples
macosunixterminaliterm2

iTerm 2 - strange issues after switching a user


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?


Solution

  • 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