1 |
On Friday, 3 December 2021 12:08:05 GMT tastytea wrote: |
2 |
> On 2021-12-03 11:17+0000 Peter Humphrey <peter@××××××××××××.uk> wrote: |
3 |
> > Hello list, |
4 |
> > |
5 |
> > Is there a way to set the colour of a bash prompt according to |
6 |
> > whether the user has SSH'd in? |
7 |
> > |
8 |
> > This machine is a compile host for some others on the LAN, and it |
9 |
> > would be helpful if it were more obvious that I'm connected to |
10 |
> > another machine. Of course, the standard prompt tells me the machine |
11 |
> > name, but something more conspicuous would help. |
12 |
> |
13 |
> When you are connected via SSH, the environment variable SSH_CONNECTION |
14 |
> is set. I store the color in a variable and set it to yellow if |
15 |
> `[[ -n "${SSH_CONNECTION}" ]]`. I can't give you the exact snippet |
16 |
> since I use Zsh, but it should be possible to use a variable as color |
17 |
> in bash's prompt? |
18 |
> |
19 |
> Kind regards, tastytea |
20 |
|
21 |
This link expands upon tastytea's idea: |
22 |
|
23 |
https://unix.stackexchange.com/questions/217270/change-ps1-color-when-connected-to-other-host-via-ssh |