4

It's not a common scenario, but I find myself accidentally inserting commands into the wrong terminal. I haven't damaged anything important yet; So before I do, what are some of the best ways to differentiate between a local and remote terminal session?

4 Answers 4

9

The two main ways to do this are to change your PS1 variable so it contains the host name, and to use different colour schemes on your terminal app for different hosts. You could also use separate colour schemes for root shells.

1
  • 1
    Changing the color of the prompt is great. My prompt is user@host, where normal users are green, and root is red. Host is a different color for each host, so it's easier to tell at a glance which system I'm in and if I'm root.
    – Mnebuerquo
    May 13, 2010 at 18:45
5

I always have user and host name in my shell prompt

1

Just to follow up on the previous answers, edit your $HOME/.bash_profile to set PS1 upon login.

PS1='\h [!]: '

The above setting will display the host name of the system plus the history number of the current command.

-1

My PS1 has a blue background on (mostly) client machines and red on the servers.

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