From 945536a29cc7bc4f3d06577ceaad67d0358690c9 Mon Sep 17 00:00:00 2001 From: Quinn Date: Tue, 18 Nov 2025 17:14:30 +0100 Subject: [PATCH] rework bash scripts to be completely, or mostly POSIX-compliant --- .bash_logout | 2 +- .bash_profile | 16 +++++++++------- .bashrc | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.bash_logout b/.bash_logout index f5f3e2e..9930ac1 100644 --- a/.bash_logout +++ b/.bash_logout @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # ~/.bash_logout # sourced when an interactive login shell exits, or a non-interactive login shell executes `exit` diff --git a/.bash_profile b/.bash_profile index 539365a..7530671 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # shellcheck disable=1091 # # ~/.bash_profile @@ -13,7 +13,7 @@ export XDG_STATE_HOME="$HOME/var/lib" # state data that should persist between export XDG_CACHE_HOME="$HOME/var/cache" # user-specific non-essential (cached) data. export PATH="$XDG_BIN_HOME:$PATH" # add our bin in front of PATH, making it take precedence -if command -v nvim &>/dev/null; then +if command -v nvim >/dev/null; then export EDITOR=nvim # use neovim as an editor export VISUAL=nvim # use neovim for visual-based editors export MANPAGER='nvim +Man!' # use neovim as a manual pager @@ -22,14 +22,16 @@ fi # coloured GCC warnings and errors export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' -# export Microsoft's bullshit outta here +# Microsoft bullshit export DOTNET_CLI_TELEMETRY_OPTOUT=1 export VCPKG_DISABLE_METRICS=1 export VCPKG_ROOT="$XDG_DATA_HOME/vcpkg" -export PATH+=":$VCPKG_ROOT" +export PATH="$PATH:$VCPKG_ROOT" # if executing interactively # execute .bashrc in the current login context -[[ $- != *i* ]] && return -[[ -z ${PS1-} ]] && retrun -[[ -f $HOME/.bashrc ]] && . "$HOME/.bashrc" +case $- in +*i*) return ;; +esac +[ -z "${PS1-}" ] && return +[ -f "$HOME/.bashrc" ] && . "$HOME/.bashrc" diff --git a/.bashrc b/.bashrc index e0fe1bf..50beefa 100644 --- a/.bashrc +++ b/.bashrc @@ -5,17 +5,18 @@ # sourced upon launch of an interactive shell, which isn't a login shell has been executed # -# If not running interactively, don't do anything -[[ $- != *i* ]] && return -[[ -z "${PS1-}" ]] && return +case $- in +*i*) return ;; +esac +[ -z "${PS1-}" ] && return # lazy loading of ssh agents _lazy_ssh() { - if [[ -z $SSH_AUTH_SOCK ]]; then - eval "$(ssh-agent -s)" &>/dev/null - ssh-add "$HOME/.ssh/github" &>/dev/null - ssh-add "$HOME/.ssh/gitea" &>/dev/null - ssh-add "$HOME/.ssh/admin@homeserver" &>/dev/null + if [ -z "$SSH_AUTH_SOCK" ]; then + eval "$(ssh-agent -s)" >/dev/null + ssh-add "$HOME/.ssh/github" >/dev/null + ssh-add "$HOME/.ssh/gitea" >/dev/null + ssh-add "$HOME/.ssh/admin@homeserver" >/dev/null fi } # aliases so the function is called beforehand @@ -73,4 +74,4 @@ shopt -s globstar # enable globstar (**/*) [ -f "$HOME/.bash_aliases" ] && . .bash_aliases # cute lil hyfetch :3 -[[ $TERM == "xterm-kitty" ]] && fastfetch +[ "$TERM" == "xterm-kitty" ] && fastfetch