Use $HOSTNAME instead of $(hostname) in .bash*

This commit is contained in:
Darren 'Tadgy' Austin 2021-03-26 05:37:13 +00:00
commit 233680cd76
2 changed files with 4 additions and 4 deletions

View file

@ -121,7 +121,7 @@ hash screen >/dev/null 2>&1 && {
screen_attach
# Output some screen info.
export SCREENDIR="$HOME/.screen-$(hostname --short)"
export SCREENDIR="$HOME/.screen-${HOSTNAME%%.*}"
if [[ ! -e ~/.hushlogin ]]; then
if [[ ! -z "$STY" ]]; then
echo "Screen $STY, window $WINDOW."

View file

@ -158,7 +158,7 @@ screen_attach() {
# Only continue if it's not a remote connection, and not inside screen already.
[[ -z "$SSH_TTY" ]] && [[ -z "$STY" ]] && {
TTY="$(tty | cut -d/ -f3-)"
SCREENS="$(screen -list | fgrep -v "Dead" | fgrep "$HOSTNAME" | fgrep "${TTY//\//-}")"
SCREENS="$(screen -list | fgrep -v "Dead" | fgrep "${HOSTNAME%%.*}" | fgrep "${TTY//\//-}")"
case "$(echo "${SCREENS:--n}" | wc -l)" in
0)
# No screens found - start a new instance.
@ -166,7 +166,7 @@ screen_attach() {
;;
1)
# Just one screen - reconnect.
screen -dr "${TTY//\//-}.$HOSTNAME"
screen -dr "${TTY//\//-}.${HOSTNAME%%.*}"
;;
*)
# Multiple screens - output a list
@ -185,7 +185,7 @@ IGNOREEOF=0
# History control.
HISTCONTROL="ignoredups"
HISTFILE="$HOME/.bash_history-$(hostname --short)"
HISTFILE="$HOME/.bash_history-${HOSTNAME%%.*}"
HISTFILESIZE=100000
HISTIGNORE="bg:bg *:fg:fg *:jobs:exit:clear:history"
HISTSIZE=-1