summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/system/opt/openslx/bashrc.inc
blob: 98711d47d51e167124c9ce0f3559edd11a1afbf2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
ifname="$( ifconfig | grep -oEm1 '^e\w+' )"
slxip="$( ip -4 a show "$ifname" 2>/dev/null | grep -m1 '^\s*inet ' | awk '{print $2}' )"
[ -z "$slxip" ] && slxip="$( ip -4 a | grep '^\s*inet '| grep -vFm1 ' 127.' | awk '{print $2}' )"
slxip=${slxip%/*}
[ -z "$slxip" ] && read -r _ _ slxip _ <<<"$SSH_CONNECTION"
[ -z "$slxip" ] && slxip="noip???"
slxcol=32
(( UID == 0 )) && slxcol=31
PS1="\[\033[01;${slxcol}m\]\u\[\033[00m\]@\[\033[01;32m\]\h \[\033[00m\]($slxip)
\[\033[01;34m\]\w\[\033[00m\] # "
unset ifname slxip slxcol
# We always want to run this as root; sudo is a noop in case we already are.
alias tmate='sudo tmate'