1 |
On 2021-12-03 11:17+0000 Peter Humphrey <peter@××××××××××××.uk> wrote: |
2 |
|
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 |
-- |
22 |
Get my PGP key with `gpg --locate-keys tastytea@××××××××.de` or at |
23 |
<https://tastytea.de/tastytea.asc>. |