Add updated bash startup files.

This commit is contained in:
Darren 'Tadgy' Austin 2024-08-25 20:36:06 +01:00
commit ee8f5f528a
11 changed files with 633 additions and 593 deletions

View file

@ -1,17 +1,14 @@
#!/bin/bash - not strictly necessary, but helps nano with syntax highlighting.
# Bash shell environmental set up.
# Source bash specific set up,
[[ -f "$HOME/.bashrc" ]] && . "$HOME/.bashrc"
# Environment.
export EDITOR="nano"
# Common environment.
export LANG="en_GB.UTF-8"
export LC_COLLATE="POSIX" # 'C' causes issues with some applications
# export LC_CTYPE="POSIX" # Not sure why I set this in the first place...
export LESS='-RM -j.5 -i -PM?f%F:stdin. -- Page %dt of %D -- %lt/%L (%Pt\%)$'
export PAGER="less"
export VISUAL="$EDITOR"
hash less >/dev/null 2>&1 && export PAGER="less"
hash lesspipe >/dev/null 2>&1 && eval "$(SHELL=/bin/sh lesspipe)"
hash nano >/dev/null 2>&1 && export EDITOR="nano" && export VISUAL="$EDITOR"
# Platform specific set up.
PLATFORM="${PLATFORM:-$(uname -s)}"
@ -21,9 +18,10 @@ if [[ "$PLATFORM" = "Linux" ]]; then
export I_WANT_A_BROKEN_PS=1
export LYNX_CFG="$HOME/.lynx.cfg"
export LYNX_LSS="$HOME/.lynx.lss"
export MANPAGER="less"
export MANPAGER="$PAGER"
export MANPATH="$HOME/.local/share/man:$MANPATH"
export PATH="/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
hash dircolors >/dev/null 2>&1 && eval "$(dircolors -b "$HOME/.dir_colors")"
hash gpgconf >/dev/null 2>&1 && {
GPG_SOCK_DIR="$(gpgconf --list-dirs | awk -F : '/socketdir:/ { print $2 }')"
@ -33,6 +31,7 @@ if [[ "$PLATFORM" = "Linux" ]]; then
unset GPG_SOCK_DIR
}
hash gpg-connect-agent >/dev/null 2>&1 && gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
[[ ! -e "$HOME/.config/lxterminal/lxterminal.conf" ]] && (
cd "$HOME/.config/lxterminal" 2>/dev/null || exit 1
[[ -e "lxterminal.conf-${HOSTNAME%%.*}" ]] && ln -sf "lxterminal.conf-${HOSTNAME%%.*}" "lxterminal.conf"
@ -46,57 +45,20 @@ else
printf "%s: %s\\n" "${BASH_SOURCE##*/}" "unsupported platform: $PLATFORM" >&2
fi
# Add bin directories to PATH.
# Add local perl directories to PATH if they exist.
[[ -d "$HOME/.local/perl5/bin" ]] && export PATH="$HOME/.local/perl5/bin:$PATH"
[[ -d "$HOME/.local/perl5/sbin" ]] && export PATH="$HOME/.local/perl5/sbin:$PATH"
# Add extra bin directories to PATH if they exist.
[[ -d "$HOME/files/bin" ]] && export PATH="$HOME/files/bin:$PATH"
[[ -d "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH"
[[ -d "$HOME/bin" ]] && export PATH="$HOME/bin:$PATH"
# Screen.
hash screen >/dev/null 2>&1 && {
[[ -e "$HOME/.screenrc-${HOSTNAME%%.*}" ]] && export SCREENRC="$HOME/.screenrc-${HOSTNAME%%.*}"
export SCREENDIR="$HOME/.screen-${HOSTNAME%%.*}"
if [[ -n "$SSH_TTY" ]]; then
if [[ -n "$STY" ]]; then
# shellcheck disable=SC2154
printf "%s\\n\\n" "Screen $STY, window $WINDOW."
else
SCREENS="$(screen -ls | grep '[[:alpha:]]' | grep -E -v '^([[:digit:]]+|No) Socket(s)?')"
if [[ -n "$SCREENS" ]]; then
printf "%s\\n\\n" "$SCREENS"
else
printf "%s\\n\\n" "No screens."
fi
unset SCREENS
fi
elif [[ -n "$STY" ]]; then
# shellcheck disable=SC2154
printf "%s\\n\\n" "Screen $STY, window $WINDOW."
else
TTY="$(tty | cut -d/ -f3-)"
SCREENS="$(screen -ls | grep -F "${HOSTNAME%%.*}" | grep -F "${TTY//\//-}")"
# This has to be an echo, not printf.
case "$(echo "${SCREENS:--n}" | wc -l)" in
0)
# No screens found - start a new instance if on a tty.
# Disabled this because screens should be started on chuckie not the desktop/laptop.
# [[ "$TTY" == tty* ]] && screen
:
;;
1)
# Just one screen - reconnect if it's not dead.
if (( $(printf "%s" "$SCREENS" | grep -c -F 'Dead') == 1 )); then
printf "%s:\\n" "Found dead screen for $TTY"
printf "%s\\n" "$SCREENS" | sed -e 's/^/ /g'
else
screen -dr "${TTY//\//-}.${HOSTNAME%%.*}"
fi
;;
*)
# Multiple screens - output a list
printf "%s:\\n" "Multiple screens found for $TTY"
printf "%s\\n" "$SCREENS" | sed -e 's/^/ /g'
;;
esac
fi
unset SCREENS TTY
}
# Read in the environment from .bash_profile.d/*.
for FILE in "$HOME"/.bash_profile.d/*; do
[[ -x "$FILE" ]] && source "$FILE"
done
unset FILE
# Source bash specific set up,
[[ -f "$HOME/.bashrc" ]] && . "$HOME/.bashrc"