commit 7f505cf016e40a9c4d3836b3bca49fa67a3bec78
parent b80c1f0224d00b1356ebb39d3c16e92c2ba579bd
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Sat, 27 Mar 2021 00:40:40 -0700
Rework shell modules to be less cumbersome
- Move the include function definition to a file in PATH
- Move the reload function to the aliases module
- Remove the main module
- Remove the clunky SHELL_MODULES variable
Diffstat:
5 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/local/bin/.local/bin/include b/local/bin/.local/bin/include
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright 2021 Jacob R. Edwards
+# License: GPLv3
+#
+# include -- include shell modules
+
+include() {
+ for m in "$@"
+ do
+ . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/$m"
+ done
+}
diff --git a/local/ksh/.config/ksh.kshrc b/local/ksh/.config/ksh.kshrc
@@ -10,7 +10,9 @@ PS3='3> '
PS4='4> '
mkdir -p "$(dirname $HISTFILE)"
-test -f "$XDG_CONFIG_HOME/shell/main" && . "$XDG_CONFIG_HOME/shell/main"
test -f $XDG_CONFIG_HOME/dalias &&
eval $(awk -F'\t' '{ printf "alias -d %s=%s;", $1, $3 }' \
<$XDG_CONFIG_HOME/dalias)
+
+. include
+include aliases cd etc fs hist mpc openbsd private xorg
diff --git a/local/profile/.profile b/local/profile/.profile
@@ -32,5 +32,4 @@ export LYNX_CFG="$XDG_CONFIG_HOME/lynx/lynx.cfg"
export MANPATH=/usr/share/man:/usr/X11R6/man:/usr/local/man:/usr/local/plan9/man
export MPC_FORMAT=%file%
export PATH="$HOME/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin:/usr/games:/usr/local/plan9/bin"
-export SHELL_MODULES='aliases cd etc fs hist mpc openbsd private xorg'
export WALLPAPER_DIR="$HOME/image/wallpapers/"
diff --git a/local/shell/.config/shell/aliases b/local/shell/.config/shell/aliases
@@ -10,6 +10,7 @@ grep() egrep "$@"
mtime() stat -t '%F %T' -f%Sm%t%N "$@"
netget() curl -SsLO "$@"
pkill() command pkill -x "$@"
+reload() . "${ENV:?unset}"
sed() command sed -E "$@"
spm() tspm "$@"
diff --git a/local/shell/.config/shell/main b/local/shell/.config/shell/main
@@ -1,11 +0,0 @@
-# shell module hub
-
-include() {
- for m in "$@"
- do
- . "${XDG_CONFIG_HOME:-$HOME/.config}/shell/$m"
- done
-}
-reload() include main
-
-include $SHELL_MODULES