From 91ab592f839a8e97faabf774cd26d56e24c94bb9 Mon Sep 17 00:00:00 2001 From: Martin Blazik Date: Sun, 29 May 2022 16:15:57 +0200 Subject: [PATCH] Improve rc/ scripts --- rc/01-functions.sh | 10 +++++++--- rc/02-aliases.sh | 2 ++ rc/99-local.sh | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rc/01-functions.sh b/rc/01-functions.sh index f47c326..f11800c 100644 --- a/rc/01-functions.sh +++ b/rc/01-functions.sh @@ -1,7 +1,7 @@ # $LWS/rc/functions.sh function xlog() { - if (( $LWS_DEBUG )); then + if true_false "$LWS_DEBUG"; then echo "$@" fi } @@ -33,7 +33,7 @@ function append_path() { function append_path_try() { if [[ -e "$1" ]]; then - append_pat "$1" + append_path "$1" fi } @@ -69,13 +69,17 @@ function can_run() { function source_directory() { local mask="$1" for file in $mask; do - if [[ -f "$file" ]]; then + if [[ -e "$file" ]]; then xlog "LOAD $file" source "$file" fi done } +function source_directory_sh() { + source_directory "$1/*.sh" +} + # use: dump_args "$@" function dump_args() { for i in $*; do diff --git a/rc/02-aliases.sh b/rc/02-aliases.sh index 4d1d800..df3ae9a 100644 --- a/rc/02-aliases.sh +++ b/rc/02-aliases.sh @@ -1,3 +1,5 @@ +alias nop=':' + alias exit-when-error='set -o errexit' alias exit-when-unset-variable='set -o nounset' alias exit-when-pipe-fail='set -o pipefail' diff --git a/rc/99-local.sh b/rc/99-local.sh index 9f5bbaa..d0d0320 100644 --- a/rc/99-local.sh +++ b/rc/99-local.sh @@ -1,3 +1,4 @@ # Load user locals bashrc -source_directory "$HOME/.bashrc.d/*.sh" +source_directory_sh "$LWS/rc.local" +source_directory_sh "$HOME/.bashrc.d"