AlanGreene / starter

Dotfiles starter project for new machines
1 stars 1 forks source link

Change prompt based on user / environment #12

Closed AlanGreene closed 4 years ago

AlanGreene commented 5 years ago

https://github.com/AlanGreene/dotfiles-12/blob/master/bash/dots/prompt

react to root, SSH, etc.

#!/usr/bin/env bash

if [[ $(id -u) -eq 0 ]]; then       # Root
    PS1="\W \[\e[31m\]::\[\e[m\] "
elif [[ -n "$SSH_CLIENT" ]]; then   # SSH session
    PS1="\W \[\e[33m\]::\[\e[m\] "
else                                # Normal
    PS1="\W \[\e[1m\]::\[\e[m\] "
fi