From 2191bf4e197b48046a7b240adfcafc72dfcd0fa5 Mon Sep 17 00:00:00 2001 From: Alan Guedes Date: Tue, 22 Aug 2023 12:02:28 +0100 Subject: [PATCH] load [cmd].bash after load os_any.bash --- README.md | 23 +++++++++++------------ init.sh | 28 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 69ef292e..d196fd35 100644 --- a/README.md +++ b/README.md @@ -12,31 +12,30 @@ flowchart LR subgraph bash-helpers init["init.sh"] any["os_any.bash"] - win["os_win.bash"] - ubu["os_ub.bash"] - mac["os_mac.bash"] command-dependent[" - commands/COMMAND_NAME_1.bash - commands/COMMAND_NAME_2.bash + commands/[cmd_name].bash ... "] + win["os_win.bash"] + ubu["os_ub.bash"] + mac["os_mac.bash"] scripts_sh[" - scripts/SCRIPT_1.sh + scripts/[script].sh ... "] scripts_ps1[" - scripts/SCRIPT_1.ps1 + scripts/win_[script].ps1 ... "] end bashrc --> |"load"| init init --> |"load"| any any --> |"alias to each *.sh"| scripts_sh - win --> |"alias to each *.ps1"| scripts_ps1 - init --> |"if $OSTYPE==msys* || -n $WSL_DISTRO_NAME then load"| win - init --> |"if $OSTYPE==linux* then load"| ubu - init --> |"if $OSTYPE==mac* then load"| mac - init --> |"if type COMMAND_NAME then load"| command-dependent + win --> |"alias to each win_*.ps1"| scripts_ps1 + init --> |"load if $OSTYPE==msys* || -n $WSL_DISTRO_NAME"| win + init --> |"load if $OSTYPE==linux*"| ubu + init --> |"load if $OSTYPE==mac*"| mac + init --> |"load if type cmd_name"| command-dependent ``` ## Install diff --git a/init.sh b/init.sh index 9cee5a7b..b0fbff13 100644 --- a/init.sh +++ b/init.sh @@ -3,11 +3,26 @@ BH_DIR="$(dirname "${BASH_SOURCE[0]}")" ######################### -# load os_.bash files +# load os_any.bash ######################### source "$BH_DIR/os_any.bash" +######################### +# load .bash files +######################### + +for file in "$BH_DIR/commands/"*.bash; do + command_name=$(basename ${file%.*}) + if type $command_name &>/dev/null; then + source $file + fi +done + +######################### +# load any os_.bash files +######################### + if [[ $OSTYPE == msys* || -n $WSL_DISTRO_NAME ]]; then source "$BH_DIR/os_win.bash" fi @@ -19,14 +34,3 @@ fi if [[ $OSTYPE == darwin* ]]; then "$BH_DIR/os_mac.bash" fi - -######################### -# load .bash files -######################### - -for file in "$BH_DIR/commands/"*.bash; do - command_name=$(basename ${file%.*}) - if type $command_name &>/dev/null; then - source $file - fi -done