Skip to content

Commit

Permalink
rename commmands folder to programs
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlivio committed Nov 16, 2023
1 parent 8aadc9d commit 61d91c6
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 29 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# bash-helpers

Template to easily create multi-OS bash helpers for Windows (MSYS2/GitBash/WSL), Ubuntu, and Mac. It is useful to let you organize helpers in `OS-dependent` or `command-dependent`. Diagram below ilustrate how the [init.sh](init.sh) load `OS-dependent` from `os_*.bash` (files after testing `$OSTYPE`) and load `command-dependent` from `commands/*.bash` (after testing `type <command>`). At Windows, it also load ps1 functions from `os_win.ps1`.
Template to easily create multi-OS bash helpers for Windows (MSYS2/GitBash/WSL), Ubuntu, and Mac. It is useful to let you organize helpers in `OS-dependent` or `program-dependent`. Diagram below ilustrate how the [init.sh](init.sh) load `OS-dependent` from `os_*.bash` (files after testing `$OSTYPE`) and load `program-dependent` from `programs/<program>.bash` (after testing `type <program>`). At Windows, it also load ps1 functions from `os_win.ps1` as alias.
The project logo refers to the synthetic chemical element Bohrium, which also has BH's initials.

```mermaid
Expand All @@ -12,16 +12,16 @@ flowchart LR
init["bash-hepers/init.sh"]
anyos["os_any.bash"]
oswinps1["os_win.ps1"]
command-dependent["
commands/[cmd_name].bash
program-dependent["
programs/[program].bash
...
"]
win["os_win.bash"]
ubu["os_ub.bash"]
mac["os_mac.bash"]
bashrc --> |"load"| init
init --> |"load"| anyos
anyos --> |"load if cmd_name"| command-dependent
anyos --> |"load if type program"| program-dependent
win --> |"bash alias to each function at"| oswinps1
init --> |"load if $OSTYPE==msys* || -n $WSL_DISTRO_NAME"| win
init --> |"load if $OSTYPE==linux*"| ubu
Expand All @@ -40,7 +40,7 @@ The bash-helpers project has two requirements: a `bash shell` and `git`. So, run

Alternative, you can see the [skel/.bashrc](skel/.bashrc) as example.

On Win, you run the above command at GitaBash installed with [GitForWindows](https://gitforwindows.org). If you also use WSL, you can share the same BH repo by doing a symbolic link to it with `ln -s /mnt/c/<user>/.bh ~/.bh`.
On Win, you run the above program at GitaBash installed with [GitForWindows](https://gitforwindows.org). If you also use WSL, you can share the same BH repo by doing a symbolic link to it with `ln -s /mnt/c/<user>/.bh ~/.bh`.

## OS-dependent samples

Expand Down Expand Up @@ -106,7 +106,7 @@ See more Mac helpers in [os_mac.bash](os_mac.bash).

See more Win helpers in [os_win.bash](os_win.bash).

## command-dependent samples
## program-dependent samples

### Python

Expand All @@ -118,7 +118,7 @@ See more Win helpers in [os_win.bash](os_win.bash).
* `conda_env_create_from_enviroment_yml`: create env from environment.yml.
* `conda_env_update_from_enviroment_yml`: update env from environment.yml.

See more helpers in [commands/python.bash](commands/python.bash).
See more helpers in [programs/python.bash](programs/python.bash).

### convert

Expand All @@ -128,24 +128,24 @@ See more helpers in [commands/python.bash](commands/python.bash).
### Docker

* `docker_prune`: clean unused images and containers
* `docker_run_at_same_folder`: run, from an image, a command line using the current folder as the working folder
* `docker_run_at_same_folder`: run, from an image, a program line using the current folder as the working folder

See more helpers in [commands/docker.bash](commands/docker.bash).
See more helpers in [programs/docker.bash](programs/docker.bash).

### others

See other commands at:

* [commands/adb.bash](commands/adb.bash).
* [commands/cmake.bash](commands/cmake.bash).
* [commands/ffmpeg.bash](commands/ffmpeg.bash).
* [commands/git.bash](commands/git.bash).
* [commands/gs.bash](commands/gs.bash).
* [commands/lxc.bash](commands/lxc.bash).
* [commands/meson.bash](commands/meson.bash).
* [commands/pandoc.bash](commands/pandoc.bash).
* [commands/wget.bash](commands/wget.bash).
* [commands/youtube-dl.bash](commands/youtube-dl.bash).
See other programs at:

* [programs/adb.bash](programs/adb.bash).
* [programs/cmake.bash](programs/cmake.bash).
* [programs/ffmpeg.bash](programs/ffmpeg.bash).
* [programs/git.bash](programs/git.bash).
* [programs/gs.bash](programs/gs.bash).
* [programs/lxc.bash](programs/lxc.bash).
* [programs/meson.bash](programs/meson.bash).
* [programs/pandoc.bash](programs/pandoc.bash).
* [programs/wget.bash](programs/wget.bash).
* [programs/youtube-dl.bash](programs/youtube-dl.bash).

## References

Expand Down
8 changes: 4 additions & 4 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ if [[ $OSTYPE == darwin* ]]; then
"$BH_DIR/os_mac.bash"
fi

# load <command>.bash files
# load <program>.bash files

for file in "$BH_DIR/commands/"*.bash; do
command_name=$(basename ${file%.*})
if type $command_name &>/dev/null; then
for file in "$BH_DIR/programs/"*.bash; do
program=$(basename ${file%.*})
if type $program &>/dev/null; then
source $file
fi
done
File renamed without changes.
8 changes: 4 additions & 4 deletions commands/cmake.bash → programs/cmake.bash
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
function cmake_configure_debug() {
if test -e CMakeLists.txt; then
cmake -B _build-Debug-$WSL_DISTRO_NAME$OS -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug "$@"
cmake -B _build-Debug-$WSL_DISTRO_NAME$OS -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug "$@"
else
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug "$@"
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug "$@"
fi
}

function cmake_configure_release() {
if test -e CMakeLists.txt; then
cmake -B _build-Release-$WSL_DISTRO_NAME$OS -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "$@"
cmake -B _build-Release-$WSL_DISTRO_NAME$OS -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "$@"
else
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "$@"
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "$@"
fi
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 61d91c6

Please sign in to comment.