On 2021-12-03 11:17+0000 Peter Humphrey <[email protected]> wrote:

> Hello list,
> 
> Is there a way to set the colour of a bash prompt according to
> whether the user has SSH'd in?
> 
> This machine is a compile host for some others on the LAN, and it
> would be helpful if it were more obvious that I'm connected to
> another machine. Of course, the standard prompt tells me the machine
> name, but something more conspicuous would help.

When you are connected via SSH, the environment variable SSH_CONNECTION
is set. I store the color in a variable and set it to yellow if 
`[[ -n "${SSH_CONNECTION}" ]]`. I can't give you the exact snippet
since I use Zsh, but it should be possible to use a variable as color
in bash's prompt?

Kind regards, tastytea

-- 
Get my PGP key with `gpg --locate-keys [email protected]` or at
<https://tastytea.de/tastytea.asc>.

Attachment: pgpPmG8W_1HhU.pgp
Description: Digitale Signatur von OpenPGP

Reply via email to