From c6dc8e44874f28292da149b63b0c3e9b1f328065 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Thu, 23 Feb 2023 10:03:47 -0800 Subject: [PATCH] moved reload_user, add editor function, add wheel to groups check add follow links option to _find user hostnamectl to get host name --- load.sh | 6 ++++++ load/01-basic | 28 ++++++++++------------------ load/02-system-path | 2 +- load/logging | 1 - modules/utility/file.lib | 10 +++++++--- shell.env | 2 +- 6 files changed, 25 insertions(+), 24 deletions(-) delete mode 100644 load/logging diff --git a/load.sh b/load.sh index 5c29443..01a09d4 100755 --- a/load.sh +++ b/load.sh @@ -21,6 +21,12 @@ reload_shell () { source $BASH_SHELL_BASE/load.sh $@ } +reload_user() { + save=$PWD + exec su -l $USER + cd $save +} + load_custom_shell_env () { [[ -f $BASH_SHELL_HOST/shell.env ]] && source $BASH_SHELL_HOST/shell.env [[ -f $BASH_SHELL_USER_DIR/shell.env ]] && source $BASH_SHELL_USER_DIR/shell.env diff --git a/load/01-basic b/load/01-basic index 1e022b6..c477e0f 100644 --- a/load/01-basic +++ b/load/01-basic @@ -1,15 +1,11 @@ #!/bin/bash -# 00 will get loaded first -## - -user_reload() { - save=$PWD - exec su -l $USER - cd $save - -} +if [[ ! $(command -v arch) ]]; then + function arch() { + uname -m + } +fi function function_list { if [ $1 ]; then @@ -74,21 +70,17 @@ grep -rnswl $1 -e $2 | more } # edit files -# set the system editor using EDITOR environment variable -editor() { ${EDITOR} $1; } +# echo set the system editor using EDITOR environment variable +edit() { ${EDITOR:-nano} $@; } +gedit() { ${GEDITOR:-xed} $@; } + add-repo-key () { gpg --keyserver keyserver.ubuntu.com --recv-key $1 gpg -a --export $1 | sudo apt-key add - } -osinfo () { - hostnamectl - echo kernel: $(uname -r) - echo machine: $(arch) - cat /etc/os-release - cat /etc/upstream-release/lsb-release -} + alias ssudo="ssudo " \ No newline at end of file diff --git a/load/02-system-path b/load/02-system-path index 6066746..224a517 100644 --- a/load/02-system-path +++ b/load/02-system-path @@ -2,7 +2,7 @@ module_load system-path # if sudo user then give access to these paths - if [[ $(groups | grep sudo ) ]]; then + if [[ $(groups | grep -e sudo -e wheel ) ]]; then export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin fi diff --git a/load/logging b/load/logging deleted file mode 100644 index 42de141..0000000 --- a/load/logging +++ /dev/null @@ -1 +0,0 @@ -module_load logit \ No newline at end of file diff --git a/modules/utility/file.lib b/modules/utility/file.lib index 349d0ab..830b423 100644 --- a/modules/utility/file.lib +++ b/modules/utility/file.lib @@ -76,7 +76,7 @@ local HIDDEN declare OPTION declare OPTARG declare OPTIND -while getopts 't:p:d:e:n:f:h' OPTION; do +while getopts 't:p:d:e:n:f:hl' OPTION; do case "$OPTION" in t) TYPE=$OPTARG @@ -108,6 +108,10 @@ case "$OPTION" in HIDDEN=true # echo "SOURCING TO DEPTH (0=any)" "$DEPTH" ;; + + l) + LINKS=-L + ;; *) echo unknown option $OPTION ;; @@ -134,7 +138,7 @@ fi # echo dir $DIR local FIND -FIND="command find $DIR" +FIND="command find $LINKS $DIR" FIND+=$([ ! $DEPTH == 0 ] && echo " -maxdepth $DEPTH ") # FIND+=" -type $([ $TYPE ] && echo "$TYPE" || echo "f")" TYPE=${TYPE:-f} @@ -206,7 +210,7 @@ source_dir () { debug source_dir passed arguments: $* debug function: source_dir local FILES - FILES=$(_find "$@") # find function + FILES=$(_find -l "$@") # find function # echo $FILES >&2 [[ $? -ne 0 ]] && return 1 for f in $FILES; do diff --git a/shell.env b/shell.env index fe83644..24b4e08 100755 --- a/shell.env +++ b/shell.env @@ -90,7 +90,7 @@ BASH_SHELL_ANY_NETWORK=$parent/any/network export BASH_SHELL_DIRS # machine specific shell -BASH_SHELL_HOST=$parent/$(hostname) +BASH_SHELL_HOST="$parent/$(hostnamectl hostname)" # BASH_SHELL_HOST= # if there is a host directory add it to list and export env var # [[ -d $BASH_SHELL_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_HOST " && export BASH_SHELL_HOST