|
|
@ -25,7 +25,7 @@ if [ -z "$directory" ]; then |
|
|
|
directory=$(pwd) |
|
|
|
directory=$(pwd) |
|
|
|
else |
|
|
|
else |
|
|
|
# If a directory path was provided, expand the '~' character if necessary |
|
|
|
# If a directory path was provided, expand the '~' character if necessary |
|
|
|
directory="${directory/#\~/$HOME}" |
|
|
|
directory="$(echo "$directory" | sed "s|^~|$HOME|")" |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Check if the directory exists |
|
|
|
# Check if the directory exists |
|
|
@ -41,7 +41,7 @@ if [ ! -f "$HOME/.bashrc" ]; then |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Check if the directory is already in the PATH variable |
|
|
|
# Check if the directory is already in the PATH variable |
|
|
|
if grep -q "$directory" "$HOME/.bashrc"; then |
|
|
|
if grep -q "PATH=$directory" "$HOME/.bashrc"; then |
|
|
|
# If the directory is already in the PATH variable, check if the action is 'add' |
|
|
|
# If the directory is already in the PATH variable, check if the action is 'add' |
|
|
|
if [ "$action" = "add" ]; then |
|
|
|
if [ "$action" = "add" ]; then |
|
|
|
echo "The directory is already in your PATH." |
|
|
|
echo "The directory is already in your PATH." |
|
|
@ -54,8 +54,8 @@ if grep -q "$directory" "$HOME/.bashrc"; then |
|
|
|
else |
|
|
|
else |
|
|
|
# If the directory is not in the PATH variable, check if the action is 'add' |
|
|
|
# If the directory is not in the PATH variable, check if the action is 'add' |
|
|
|
if [ "$action" = "add" ]; then |
|
|
|
if [ "$action" = "add" ]; then |
|
|
|
# If the action is 'add', append the directory to the PATH variable in the '.bashrc' file |
|
|
|
# If the action is 'add', prepend the directory to the PATH variable in the '.bashrc' file |
|
|
|
echo "export PATH=\$PATH:$directory" >> "$HOME/.bashrc" |
|
|
|
echo "export PATH=$directory:\$PATH" >> "$HOME/.bashrc" |
|
|
|
echo "The directory has been added to your PATH." |
|
|
|
echo "The directory has been added to your PATH." |
|
|
|
else |
|
|
|
else |
|
|
|
# If the action is 'remove' and the directory is not in the PATH variable, display an error message |
|
|
|
# If the action is 'remove' and the directory is not in the PATH variable, display an error message |
|
|
|