Version control your
.bashrc file with Github Gist
Install Gist on your machine
If you have ruby installed (how to install ruby):
sudo gem install gist
If you're using Bundler:
source :rubygems gem 'gist'
For OS X, gist lives in Homebrew
brew install gist
Log into Gist with your Github account
If you want to associate your gists with your GitHub account, you need to login with gist. It doesn't store your username and password, it just uses them to get an OAuth2 token (with the "gist" permission).
gist --login Obtaining OAuth2 access_token from github. GitHub username: ConradIrwin GitHub password: 2-factor auth code: Success! https://github.com/settings/tokens
This token is stored in
~/.gist and used for all future gisting. If you need to
you can revoke it from https://github.com/settings/tokens, or just delete the
file. If you need to store tokens for both github.com and a Github Enterprise instance
you can save your Github Enterprise token in
"github.example.com" is the URL for your Github Enterprise instance.
After you've done this, you can still upload gists anonymously with
gist -a a.rb
Create a Gist with your bashrc file
.bashrc file to your account as a private gist using the following command
gist -p -o -d "My .bashrc" ~/.bashrc
-p specifies that you want this file to be private,
-o will open a new browser tab with the gist page as soon as it's uploaded, and
-d is used to add a description for your file.
Create an alias for updating your file
.bashrc file with the editor of your choice, in this case I'll be using atom.
sudo atom ~/.bashrc
At the end of the file add the following command
#Gist Bashrc alias alias gistbash="gist -u GIST_ID ~/.bashrc"
Save the file and close out your editor.
Commit your changes
Either open a new terminal window or source your
.bashrc by using the following command
Now you can run your alias every time after making a change to your
.bashrc file to update your gist.
After you run the command you should be able to see the changes reflected on the gist!