March 05, 2021
Art by my buddy Loor Nicolas
You get a new computer, you back up all your files but…
OH! you forgot to back up your ~/.bashrc
or ~/.zshrc
where all your custom aliases and functions live! Now you need to start over with them…
To save you this headache, I’m sharing my super-useful custom alias for updating my shell config that does the following:
Let’s set it up.
This tutorial assumes you’re using zsh. If your are using bash, just replace
zsh
and.zshrc
bybash
and.bashrc
in the next commands. You can find out which shell you’re using by runningecho $0
.
Creating a secret Gist.
https://gist.github.com/jportella93/616c872593daf91781d6842c9829b1f0
so I’m copying 616c872593daf91781d6842c9829b1f0
.~/.zshrc
include this line:alias zshrc="gedit ~/.zshrc && \
gist-paste -u 616c872593daf91781d6842c9829b1f0 ~/.zshrc && \
exec zsh"
I’m using gedit as text editor but you can use any other like
nano
,vim
orcode
. Then replace the gist identifier616c872593daf91781d6842c9829b1f0
with the one you copied in the previous step.
~/.zshrc
just type zshrc
in your CLI, make changes on your text editor, and changes will be backed up on the Gist automatically. Moreover, you’ll be able to use your updated alias right away! How cool is that?Written by Jon Portella.