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