Skip to content

Commit

Permalink
init.sh loads lib/COMMAND_NAME.bash if type COMMAND_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlivio committed Jun 28, 2023
1 parent ae7c686 commit 5d1750e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ flowchart LR
os_ubu.bash
os_win.bash"]
command-dependent["
lib/adb.bash
lib/python.bash
lib/git.bash
lib/COMMAND_NAME_1.bash
lib/COMMAND_NAME_2.bash
lib/COMMAND_NAME_3.bash
...
"]
end
bashrc --> |"load"| init
init --> |"load"|any
init --> |"if OSTYPE then load"|os-dependent
init --> |"if COMMAND then load"|command-dependent
init --> |"if $OSTYPE then load"|os-dependent
init --> |"if type COMMAND_NAME then load"|command-dependent
```


Expand Down
19 changes: 6 additions & 13 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ source "$BH_DIR/os_any.bash"
case $OSTYPE in
msys*)
source "$BH_DIR/os_win.bash"
alias gs='gswin64.exe'
alias winpath='cygpath -m'
;;
linux*)
Expand All @@ -29,15 +28,9 @@ esac
# load <command>.bash files
#########################

if type adb &>/dev/null; then source "$BH_DIR/lib/adb.bash"; fi
if type cmake &>/dev/null; then source "$BH_DIR/lib/cmake.bash"; fi
if type docker &>/dev/null; then source "$BH_DIR/lib/docker.bash"; fi
if type ffmpeg &>/dev/null; then source "$BH_DIR/lib/ffmpeg.bash"; fi
if type gs &>/dev/null; then source "$BH_DIR/lib/gs.bash"; fi
if type git &>/dev/null; then source "$BH_DIR/lib/git.bash"; fi
if type lxc &>/dev/null; then source "$BH_DIR/lib/lxc.bash"; fi
if type meson &>/dev/null; then source "$BH_DIR/lib/meson.bash"; fi
if type pandoc &>/dev/null; then source "$BH_DIR/lib/pandoc.bash"; fi
if type python &>/dev/null; then source "$BH_DIR/lib/python.bash"; fi
if type wget &>/dev/null; then source "$BH_DIR/lib/wget.bash"; fi
if type youtube-dl &>/dev/null; then source "$BH_DIR/lib/youtube-dl.bash"; fi
for file in "$BH_DIR/lib/"*.bash; do
command_name=$(basename ${file%.*})
if type $command_name &>/dev/null; then
source $file
fi
done

0 comments on commit 5d1750e

Please sign in to comment.