When I connect over ssh to remote hosts everything is just a single font/color. I would like to have colours like I do locally e.g. green for executable and blue for symlinks etc. And such that when I run $ git diff on the ssh host it shows me diff with colours =)
Because it was xterm on the server, I figured something was wrong with
.bashrc
And indeed!
ls --color=auto
works only when you are connected to TTY. Changing everything to simply--color
in.bashrc
on the remote host and everything is in pretty colours now.This worked for me:
-t
was the key. Explained:Seems like colors were already set in
~/.bashrc
for me and 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
:Since the colors worked fine while being loggged in directly, I just un-uncommented the line
force_color_prompt=yes
in the file~/.bashrc
, that gave me colors over ssh, too:(Ubuntu 18.04 LTS)
What's the content of your XTERM env variable on the server when you connect to it?
In my case, the missing part was to have colored ls, grep, etc. which can be added by adding aliases to the .bashrc file:
etc.
I tried changing
~./bashrc
settings (both on local and remote server), but it did not seem to work.Then I noticed that
~/.bashrc
of remote server does not even get executed if I connect to it over ssh. So I made~/.bashrc
of remote server to execute by puttinngif [ -f ~/.bashrc ]; then . ~/.bashrc fi
in remote server's~/.bash_profile
. (based on https://stackoverflow.com/questions/820517/bashrc-at-ssh-login).So this solution did not require changing any
~/bashrc
files directly but it did require changing~/bash_profile
file of remote server so that~/bashrc
file of remote server got executed.In my situation, I recently installed
chef-local
and it asked me to add a line to.bash_profile
. When I sign in,.bashrc
never loads anymore, because it saw.bash_profile
.What I did was to add a line in
.bash_profile
:I logged out and back in and got my colored terminal right away.
There is a comment from "Mike E" above that contained the answer for me, but it is not only hard to read, it is kind of hard to figure out what he means if you don't use
.bashrc
a lot - and I don't.After screwing around a bit, I got the desired results by changing the following lines in
~/.bashrc
on the machine I was logging into with ssh:to:
I am thinking I could have just added "|xterm" after "color" in the first line, or dug around and figure out why ssh was using "xterm" instead of "xterm-color" and change that, but this works and I have other things to do now.
I was losing my color when connecting via a proxy because
TERM=dumb
so I fixed it: