Skip to content

Easily Add or Remove the Current Directory to the $PATH in Bash

License

Notifications You must be signed in to change notification settings

danass/Add-to-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Easily Add or Remove the Current Directory to the $PATH in Bash

This simple utility allows you to quickly add or remove the current directory to the global $PATH in Bash, making it accessible from anywhere.

To use this tool, simply add the content of the atp.sh script to your ~/.bashrc file, then source the file to activate the function.

Usage Instructions

1. Adding the Current Directory to $PATH

To temporarily add the current directory to the $PATH, run:

user@machine:~/current-directory$ atp .

Now, when you check $PATH, you should see /home/user/current-directory (or the directory you are currently in) added to the end of the path:

user@machine:~/current-directory$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/current-directory

2. Removing the Current Directory from $PATH

To remove the current directory from the $PATH, use:

user@machine:~/current-directory$ atp -r .

After running this command, the $PATH will return to its previous state, without the current directory:

user@machine:~/current-directory$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

And that’s it!

With just two simple commands, you can add or remove the current directory from your $PATH. This is especially useful for testing or running scripts without needing to permanently modify the global $PATH.

About

Easily Add or Remove the Current Directory to the $PATH in Bash

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages