Skip to content

Instantly share code, notes, and snippets.

@jordigg
Last active February 9, 2016 10:24
Show Gist options
  • Save jordigg/14a046fa107eb835f87b to your computer and use it in GitHub Desktop.
Save jordigg/14a046fa107eb835f87b to your computer and use it in GitHub Desktop.
Script to add paths to the system wide environment $PATH
#!/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