Created
November 6, 2023 10:44
-
-
Save numpde/cd3059c563f20e76157a4982f5a13dff to your computer and use it in GitHub Desktop.
Add current path to $PATH
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
#!/bin/bash | |
# This script will add the directory where it is located to the PATH | |
# if it's not already included. | |
# Get the directory of the current script, regardless of where it's called from | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | |
# Check if the directory is already in PATH | |
if [[ ":$PATH:" != *":$DIR:"* ]]; then | |
# Add the script directory to PATH for the duration of this session or | |
# any child processes started from this script | |
export PATH="$PATH:$DIR" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment