I use a local VM to remote into multiple boxes throughout the day. My preferred shell display setting is:

export TERM=xterm-256color
PS1='${debian_chroot:+($debian_chroot)}\[\e[0;31m\]\u\[\e[m\]@\[\033[01;32m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

This is set in my .bashrc. Is there a way to make this follow me from host to host?

Caveat: I don't know which hosts I'll be accessing on any given day. So pre-configuring these on each host I ssh into isn't really an option for me.


For sure. Either you replicate that to all the .bashrc of your account on the remote servers, or in the respective sshd_config of each server, you configure the AcceptEnv line to inherit TERM, PS1, and PROMPT_DIRTRIM.

So it would be (LANG and LC_* are already there on my configuration):


You also have to configure on your side in ssh_config SendEnv on the exactly same manner.

If modifying the remote side is not an option, you can pass them through ssh as long as the remote side does not overwrite them.

ssh -l user remote_server   -t  "PROMPT_DIRTRIM='test'; exec bash"
  • Sorry, I've added an edit to my question. Setting this up on each host isn't really an option for me. Thanks though :)
    – MrDuk
    Nov 18 '15 at 18:28
  • I took the comment in consideration now. Nov 18 '15 at 18:37
  • Cool, so is there a way to pass the settings automagically? Can I modify (or even alias) the stock ssh to include these?
    – MrDuk
    Nov 18 '15 at 18:41
  • -t has to come at the end. Maybe a script or some alias kung fu Nov 18 '15 at 18:46
  • ...or a function in alias. At the moment dining. Nov 18 '15 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.