commit ee8e145b14955a9d4b39ebd0e2873ec3e1bf4316
parent a869495800c06f9bbcc2fe4fed3cee5512132575
Author: Robert Russell <robert@rr3.xyz>
Date: Sat, 1 Aug 2026 17:48:07 -0700
shell: update util
Diffstat:
7 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/shell/.bash_profile b/shell/.bash_profile
@@ -2,8 +2,8 @@ true # In case anything tries prepending below comments.
# ↑↑↑ MACHINE GENERATED ↑↑↑
# ------------------------------------------------------------------------------
-[ -f "$HOME"/.profile ] && . "$HOME"/.profile
-[ -f "$HOME"/.bashrc ] && . "$HOME"/.bashrc
+sourcefile "$HOME"/.profile
+sourcefile "$HOME"/.bashrc
# ------------------------------------------------------------------------------
# ↓↓↓ MACHINE GENERATED ↓↓↓
diff --git a/shell/.bashrc b/shell/.bashrc
@@ -2,9 +2,9 @@ true # In case anything tries prepending below comments.
# ↑↑↑ MACHINE GENERATED ↑↑↑
# ------------------------------------------------------------------------------
-[ -f "$HOME"/.shinit ] && . "$HOME"/.shinit
+. "$HOME"/.shinit
is_interactive || return
-[ -f "$HOME"/.shrc ] && . "$HOME"/.shrc
+sourcefile "$HOME"/.shrc
sourcedir "$HOME"/.config/bashrc.d
# ------------------------------------------------------------------------------
diff --git a/shell/.config/shinit.d/10-util.sh b/shell/.config/shinit.d/10-util.sh
@@ -11,11 +11,6 @@ echo_lines() {
[ $# -ge 1 ] && printf "%s\n" "$@"
}
-fail() {
- echo_lines "$@" >&2
- exit 1
-}
-
is_interactive() {
if [ $# -ne 0 ]; then
echo "Usage: is_interactive" >&2
@@ -67,3 +62,12 @@ prepend_manpath() {
done
unset p
}
+
+reload_shinit() {
+ unset SHINIT_LOADED
+ sourcefile "$HOME"/.shinit
+}
+
+reload_profile() {
+ sourcefile "$HOME"/.profile
+}
diff --git a/shell/.profile b/shell/.profile
@@ -2,7 +2,7 @@ true # In case anything tries prepending below comments.
# ↑↑↑ MACHINE GENERATED ↑↑↑
# ------------------------------------------------------------------------------
-[ -f "$HOME"/.shinit ] && . "$HOME"/.shinit
+. "$HOME"/.shinit
sourcedir "$HOME"/.config/profile.d
# ------------------------------------------------------------------------------
diff --git a/shell/.shinit b/shell/.shinit
@@ -1,15 +1,26 @@
[ -n "${SHINIT_LOADED:-}" ] && return
SHINIT_LOADED=1
+sourcefile() {
+ if [ $# -ne 1 ]; then
+ echo "Usage: sourcefile FILE" >&2
+ return 1
+ fi
+
+ [ -f "$1" ] && . "$1"
+
+ return 0
+}
+
sourcedir() {
if [ $# -ne 1 ]; then
- echo "Usage: sourcedir DIR" 1>&2
+ echo "Usage: sourcedir DIR" >&2
return 1
fi
if [ -d "$1" ]; then
for f in "$1"/*.sh; do
- [ -f "$f" ] && . "$f"
+ sourcefile "$f"
done
unset f
fi
diff --git a/shell/.shrc b/shell/.shrc
@@ -1,3 +1,3 @@
-[ -f "$HOME"/.shinit ] && . "$HOME"/.shinit
+. "$HOME"/.shinit
is_interactive || return
sourcedir "$HOME"/.config/shrc.d
diff --git a/x/.xinitrc b/x/.xinitrc
@@ -1,4 +1,4 @@
-[ -f "$HOME"/.shinit ] && . "$HOME"/.shinit
+. "$HOME"/.shinit
xkbcomp "$HOME"/.local/share/keymap.xkb "$DISPLAY" || fail "failed to set keymap"
[ -f "$HOME"/.Xresources ] && xrdb -merge "$HOME"/.Xresources