Last active
February 9, 2016 10:24
-
-
Save jordigg/14a046fa107eb835f87b to your computer and use it in GitHub Desktop.
Script to add paths to the system wide environment $PATH
This file contains 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 | |
# | |
# This script adds a path to the env $PATH | |
# | |
# Run as --> ./setpath.sh yourpath | |
# | |
set -e | |
SET_PATH=$1 | |
if [ "${SET_PATH}" != "" ]; then | |
CURRENT_PATH="$(grep -o '".*"' /etc/environment | sed 's/"//g')" | |
echo 'PATH="'${SET_PATH}':'${CURRENT_PATH}'"' > /etc/environment | |
source /etc/environment | |
exec /bin/bash | |
else | |
echo "Please specify new path to be added and run as -> ./setpath.sh yourpath" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment