260621.1 · 1c5b5c9f067464e39866718ec44934a17338ac00
shell: rejigger how we load environment variables
This makes it so my environment variables are always loaded, even in non-interactive zsh or bash scripts. Previously, we were jumping through hoops to load environment variables where they are needed in certain contexts. Subsequent commits should show how this helps.
reading declarations
@@ -1,5 +1,8 @@ # vim: ft=sh sw=2 ts=2 sts=2 +# Nudge bash to read `~/.bashenv` for non-interactive scripts.+export BASH_ENV="$HOME/.bashenv"+ . "$HOME/.bashrc" if cmd-exists startx; then
@@ -0,0 +1,5 @@+# vim: ft=bash sw=2 ts=2 sts=2++[[ -f ~/.pathrc ]] && . ~/.pathrc+[[ -f ~/.aliasrc ]] && . ~/.aliasrc+[[ -f ~/.envrc ]] && . ~/.envrc
@@ -1,10 +1,7 @@ # Check for an interactive session [ -z "$PS1" ] && return -# Define aliases and generic shell variables.-[[ -f ~/.pathrc ]] && . ~/.pathrc-[[ -f ~/.aliasrc ]] && . ~/.aliasrc-[[ -f ~/.envrc ]] && . ~/.envrc+. "$HOME/.bashenv" # Setup umask. # N.B. kent is a shared system, so use more restrictive umask.
@@ -1,7 +1,7 @@ # vim: ft=sh sw=2 ts=2 sts=2 # Various settings.-if cmd-exists nvim; then+if command -v nvim &> /dev/null; then export EDITOR="nvim" else export EDITOR="vim"
@@ -1,6 +1,8 @@-if command -V startx 2>&1 > /dev/null; then+# Nudge bash to read `~/.bashenv` for non-interactive scripts.+export BASH_ENV="$HOME/.bashenv"++if cmd-exists startx; then if [[ -z "$DISPLAY" ]] && [[ "$XDG_VTNR" = 1 ]] && [[ -z "$TMUX" ]]; then- . ~/.zshrc exec ssh-agent startx "$HOME/.config/ag/startup/wingo.xinitrc" fi fi
@@ -0,0 +1,5 @@+# vim: ft=zsh sw=2 ts=2 sts=2++[[ -f ~/.pathrc ]] && . ~/.pathrc+[[ -f ~/.aliasrc ]] && . ~/.aliasrc+[[ -f ~/.envrc ]] && . ~/.envrc
@@ -1,11 +1,6 @@ # shellcheck disable=SC2034,SC2206 # vim: ft=zsh sw=2 ts=2 sts=2 -# Define aliases and generic shell variables.-[[ -f ~/.pathrc ]] && . ~/.pathrc-[[ -f ~/.aliasrc ]] && . ~/.aliasrc-[[ -f ~/.envrc ]] && . ~/.envrc- # When doing Astral work, do some custom setup. if tmux-is-astral; then . ~/.astralrc
@@ -1,6 +1,10 @@-#!/bin/bash+#!/bin/sh -if [[ "$(uname)" = *CYGWIN* ]]; then+case "$(uname)" in+ *CYGWIN*) exit 0-fi-exit 1+ ;;+ *)+ exit 1+ ;;+esac