Skip to content

Instantly share code, notes, and snippets.

@jgaydos
Created February 14, 2019 01:33
Show Gist options
  • Save jgaydos/678dfffcee7bcf843d88dd2f15b584f1 to your computer and use it in GitHub Desktop.
Save jgaydos/678dfffcee7bcf843d88dd2f15b584f1 to your computer and use it in GitHub Desktop.
Setting system variables when they wont stick
#!/bin/bash
# This is useful for setting variables when they will not stick
echo "Enter variable name: "
read variable_name
echo "Enter variable value: "
read variable_value
echo "adding " $variable_name " to einvironment variables: " $variable_value
echo "export "$variable_name"="$variable_value>>~/.bashrc
echo $variable_name"="$variable_value>>~/.profile
echo $variable_name"="$variable_value>>/etc/environment
source ~/.bashrc
source ~/.profile
echo "do you wanna restart your computer to apply changes in /etc/environment file? yes(y)no(n)"
read restart
case $restart in
y) sudo shutdown -r 0;;
n) echo "don't forget to restart your computer manually";;
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment