For the newer version of program, that’s why we have the $PATH. You put your program into one of the directories that is in your $PATH variable, then you can access your script or program from any of these like a regular program. Check the directories with echo "$PATH" | tr ':' '\n'
My custom scripts and programs directory is “~/.local/bin”, but it has to be in the $PATH variable too. Every program and script i put there can be run like any other program. You don’t even need an alias for this specific program in example.
Here is on that I actually don’t use, but want to use it in scripts. It is meant to be used by piping it. It’s simple branch with user interaction. I don’t even know if there is a standard program doing exactly that already.
# usage: yesno [prompt] # example: # yesno && echo yes # yesno Continue? && echo yes || echo no yesno() { local prompt local answer if [[ "${#}" -gt 0 ]]; then prompt="${*} " fi read -rp "${prompt}[y/n]: " answer case "${answer}" in [Yy0]*) return 0 ;; [Nn1]*) return 1 ;; *) return 2 ;; esac }