Created
February 23, 2026 19:36
-
-
Save Segmentational/853daac5ecb45a2243f70bbe5eb692c6 to your computer and use it in GitHub Desktop.
Bash Directories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # -*- Coding: UTF-8 -*- # | |
| # -*- System: Linux -*- # | |
| # -*- Usage: *.* -*- # | |
| # | |
| # Shellcheck Ignore List | |
| # | |
| # shellcheck disable=SC1073 | |
| # shellcheck disable=SC2120 | |
| # shellcheck disable=SC2071 | |
| # shellcheck disable=SC2086 | |
| # | |
| # Ensure to run shellcheck upon change(s). | |
| # | |
| # set -o verbose ::: Print shell input upon read. | |
| # set -o allexport ::: Export all variable(s) + function(s) to environment. | |
| # set -o errexit ::: Exit immediately upon pipeline'd failure. | |
| # set -o monitor ::: Output process-separated command(s). | |
| # set -o privileged ::: Ignore externals - ensures of pristine run environment. | |
| # set -o xtrace ::: Print a trace of simple commands. | |
| # set -o braceexpand ::: Enable brace expansion. Enabled by default. | |
| # set -o no-exec ::: Bash syntax debugging; reads in commands but does not execute them. | |
| # set -o pipefail ::: Ensures the pipeline return value is that of the last command to exit. | |
| # set -o history ::: Enable the use of history for the given script. | |
| # | |
| set -o pipefail | |
| set -o errexit | |
| set +o xtrace | |
| # Relative working directory -- the directory containing the calling script. | |
| function rwd() { | |
| cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd | |
| } | |
| # The git repository's root directory. | |
| function gwd() { | |
| printf "%s" "$(git rev-parse --show-toplevel)" | |
| } | |
| # Current working directory of the caller's shell process. | |
| function cwd() { | |
| pwd | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment