Skip to content

Commit

Permalink
refact init.sh loading
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlivio committed Jun 28, 2023
1 parent b0879b7 commit aab22c8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ flowchart LR
subgraph bash-helpers
init["init.sh"]
any["os_any.bash"]
os-dependent["
os_mac.bash
os_ubu.bash
os_win.bash"]
win["os_win.bash"]
ubu["os_ub.bash"]
mac["os_mac.bash"]
command-dependent["
lib/COMMAND_NAME_1.bash
lib/COMMAND_NAME_2.bash
Expand All @@ -24,9 +23,11 @@ flowchart LR
"]
end
bashrc --> |"load"| init
init --> |"load"|any
init --> |"if $OSTYPE then load"|os-dependent
init --> |"if type COMMAND_NAME then load"|command-dependent
init --> |"always load"|any
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 --> |"foreach in lib/*: if type COMMAND_NAME then load"|command-dependent
```


Expand Down
27 changes: 13 additions & 14 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ BH_DIR="$(dirname "${BASH_SOURCE[0]}")"
#########################

source "$BH_DIR/os_any.bash"
case $OSTYPE in
msys*)
source "$BH_DIR/os_win.bash"
;;
linux*)
source "$BH_DIR/os_ubu.bash"
if [[ -n $WSL_DISTRO_NAME ]]; then
source "$BH_DIR/os_win.bash";
fi
;;
darwin*)
source "$BH_DIR/os_mac.bash"
;;
esac

if [[ $OSTYPE == msys* || -n $WSL_DISTRO_NAME ]]; then
echo source "$BH_DIR/os_win.bash";
fi

if [[ $OSTYPE == linux* ]]; then
echo source "$BH_DIR/os_ubu.bash"
fi

if [[ $OSTYPE == darwin* ]]; then
echo source "$BH_DIR/os_mac.bash"
fi


#########################
# load <command>.bash files
Expand Down
2 changes: 1 addition & 1 deletion os_win.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
alias ls='ls --color=auto -I NTUSER\* -I ntuser\* -I AppData -I IntelGraphicsProfiles* -I MicrosoftEdgeBackups'
BH_LIB_PS1="$BH_DIR/scripts/"

if [[ $OSTYPE == linux* && -n $WSL_DISTRO_NAME ]]; then
if [[ -n $WSL_DISTRO_NAME ]]; then
alias winpath='wslpath -m'
elif [[ $OSTYPE == linux* ]]; then
alias winpath='cygpath -m'
Expand Down

0 comments on commit aab22c8

Please sign in to comment.