DEV Community

Sam Erickson
Sam Erickson

Posted on

Sharing your dotfiles

Why everyone should have their own dotfile repository

A good carpenter invests time and money into their tools and their workspace. They do this to improve their work flow, and make life easier for themselves, and why wouldn't they?

So why would you not want to take a few minutes to setup your programming environment to your liking? There is no reason programmers should not do the same. The biggest advantage programming workspaces have over wood shop is that setting up a dotfiles repository and configuring open source software can be done for free. Be careful though, it is far to easy to get sucked into the world of 'ricing' and spend all your time changing your color schemes, rather than actually being productive and writing something useful.

With dotfiles there is always that fine line of how far should I go with my configuration that will maximise programing speed, but still require less time than not configuring anything?

Getting started with dotfiles

I am currently working on a project to help new users who do not know where to begin in terms of setting up their dotfiles. Right now the project is focusing on swaywm, which is a tiling window manager, but later on down the road I hope to have a guide on configuring a large amount of software and window managers so that users can pick and choose what they want upon the installation of the dotfiles, but I am a long way from reaching that goal at this point link to the project.

Thats great and all but that project is intended to start you off with boiler plate files, that you are then suppose to fine tune yourself. Its a good idea to get a git repository started to keep track of every state of your dotfiles. That way if you break something, you can always get back to a working state.

There is a great guide on how to get this up and running over on Atlassian, but if you don't want to understand what is going on (which I highly recommend doing) and you just want to copy and paste working code (really you should not do this with any code that you do not fully understand the function of, as it can have detrimental effects on your systems security, not to mention break things), here is the code:

Step 1: install my dotfiles repository (skip if you prefer to use your own)

Note: doing this will overwrite any existing files in your home directory that match those in my dotfiles repository.

git clone https://github.com/samerickson/dotfiles.git
cd dotfiles
install.sh
Enter fullscreen mode Exit fullscreen mode

Step 2: Setting up your personal repository

Initialize the git bare repository.

git init --bare ~/.dotfiles
Enter fullscreen mode Exit fullscreen mode

Create an alias to for accessing the repository.
This makes dotfiles function like git, but rather than the .git with a few important differences. Again, if you want to learn more checkout Atlassian's tutorial on the subject.

# Add this to your ~/.bashrc
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

# Source your ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Step 3: Adding your files

Now its time to add all the files you want to be included in your dotfiles repository (be very careful you do not upload any information you do not wish to publicly disclose at this point as files you add will end up public on github. Do not add and pgp keys, ssh keys, passwords, or personal information).

# The syntax is just like `git add` but instead of `git`, we write `dotfiles`
dotfiles add .bashrc
dotfiles add .profile
Enter fullscreen mode Exit fullscreen mode

Step 4: Setup the Github side of things

Head over to Github and login. Next, create a new repository. Github will then give you instructions on how to "...push an existing repository from the command line". Follow those instructions and you are done.

Top comments (0)