There are a large number of not very helpful answers on this question all over the place. I have tried several. Some would require me to change settings on each remote machine I access. Some promised to function with only a few changes on my local machine, but failed.

This question collects several of the solutions I have tried.

So, first: Is it possible to change settings on my local machine, such that syntax highlighting is enabled for all machines I remote into by ssh?

If so, how?

Note that I am using Bash for Ubuntu on Windows 10, and mostly connect to machines running Ubuntu or Debian.

The commands/programs for which I would particularly like to have highlighting are:

ls stuff
history | grep stuff
vim stuff

2 Answers 2


This answer does not deal with syntax highlighting specifically, but rather the problem of keeping consistent configurations on several machines.

You can't easily change the behaviour of utilities on a remote system through configuration changes on your local system, especially not if you're looking at configuring an array of different applications.

If your home directory is mounted on a network share, like NFS, then local modifications to e.g. ~/.bashrc or other files on you local machine will obviously carry through to the remote systems if they mount the same share.

The next step (if sharing the home directory on the different systems is not doable) would be to set up your local configurations the way you want them to be, and then copy them across to the remote systems using either scp or rsync or something similar. It may be a good idea to write a simple script to do this if you plan on tweaking the local configurations.

Such a script could be as simple as (untested)


configs=( "$HOME/.bash_profile" "$HOME/.bashrc" )
remotes=( "host1" "host2" )

for remote in "${remotes[@]}"; do
   scp "${configs[@]}" "$remote:"

The next step up from this would be to keep the relevant configuration files in a network-aware file revision control system of some description, like Git. That would additionally allow you to create branches for specific machines or flavours of Unix while also making it easy for you to access the configurations over the network.

Also note that different utilities, although using the same name, may be different in their implementation or version on different systems and therefore require different configuration. This means that one configuration for e.g. Bash here might break your shell there. One obvious source of such breakage is differences between Bash version 3 and Bash version 4, or the fact that some (non-Linux) systems do not use GNU coreutils (which provides ls and other similar shell tools).

I work around differences in file system layout (another issue when trying to set up a shell whose initialization scripts are shared between accounts on different Unices, which requires me to set PATH differently on different hosts) in my ~/.profile (I'm using ksh93 rather than bash) like this:

PATH="$( getconf PATH )"
case "$(uname -s)" in
    OpenBSD) PATH="$PATH:/usr/local/sbin:/usr/games" ;;
    NetBSD)  PATH="$PATH:/usr/X11R7/bin" ;;

Getting color over ssh is not always easy to accomplish.

You will have to ensure, that all the config files you need are copied to the other hosts. Vim requires certain settings for colors, which are set in .vimrc and .bashrc. This blog post describes how you can automatically copy your dotfiles to whichever machine you connect to.

It uses LocalCommand, the ability of the OpenSSH client to execute commands on the local machine.

For completeness, the command is reprinted here with corrections for bash: PermitLocalCommand yes LocalCommand tar c -C${HOME} .bashrc .vim .vimrc \ | ssh -o PermitLocalCommand=no %n "tar mx -C${HOME}.

Depending on how you color the output of ls or grep, you may require additional config files.

The above tar ssh tar is a command pattern, that can be seen quite often and allows to copy several files to a remote machine.

If this is not resolving your problem, you would have to provide more information. Are you using mintty? Did you set TERM? What does your .vimrc and .bashrc look like? Which colorscheme do you want to use in vim? Are you using any fancy coloring tools? ...

  • I have edit and reposted my original post. I was a little offended, that it has been deleted and I hope that this answer is better.
    – mike
    Apr 22, 2017 at 2:37

You must log in to answer this question.

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