I want shell customizations made in my dotfiles to be both seamless and permanent.
So before we start customizing our shell, let’s take five minutes and put our dotfiles in a git repostiroy so we can reproduce our environment and remove friction to future updates.
First we’re going to create a new git repo in whatever directory we keep our code in. (For me, it’s in
Then we’re going to make an install script to make installs automated in the future.
We’re going to keep our profile in a
zshrc file in source control and use the
ln command to make a symbolic link to it at
~/.zshrc (the default place zsh will look for a profile).
We’re also going to delete an existing
~/.zshrc if it exists.
(If you have anything existing in your
~/.zshrc make sure you back it up now.)
/install.sh we write:
To make it executable, we
chmod 755 ./install.sh
Now we’re going to have to actually create a
zshrc. Let’s just write something basic for now to make sure our script works.
Save this and run
./install.sh and bam, we have a
.zshrc. However, you might notice our current shell doesn’t actually have our changes. We need to open a new shell (our run
source ~/.zshrc) to see our new
l command. This is a lot of friction to make future changes, so lets write two new functions in our
zshrc. to make updates seamless next time.
(You can replace
vi with your editor of choice, but
editzsh really shines if you use a terminal based editor, since
reprofile will automatically run and resource your profile after you exit your terminal based editor.)
That’s it for our starter template! If you don’t want to type that manually you can fork all the code we just wrote or peak at my existing dotfiles for some ideas and to see where this series is heading.