Easily Manage Dot Files (Config Files)

ujwal dhakal
2 min readFeb 28, 2021

Whenever I migrated from an old laptop to a new laptop or re-installed the whole OS, I always ended up copying all the config files(Ide configuration, bash history, app profiles, etc) in a hard disk.

I either ended up copying all un-necessary configs(by zipping all) from the home folder or if I pick particular configs, I keep on missing things.

Even if I manage to zip all those things, storing them was another big challenge for me. Storing data comes with a cost as one would need to preserve it by storing locally or in any cloud. Updating the configs is even harder as I have to manually repeat all these steps.

So I started using Git to track my config files, so I created a Private Repo where I could push my all config files.

At first, I created a bash script with the name `sync. sh` inside directory dotfiles


declare -a filesToSync=(".bashrc" ".bash_history" ".zshrc" ".zsh_history" ".gitignore_global" ".gitconfig")
## now loop through the above array
for i in "${filesToSync[@]}"
cp ~/$i ~/dotfiles/$i
# or do whatever with individual element of the array
declare -a foldersToSync=(".config/Terminator",".config/JetBrains") ## now loop through the above array
for i in "${foldersToSync[@]}"
cp -r ~/$i ~/dotfiles
## or do whatever with individual element of the array

So after running bash sync.sh the script would copy all my local config files and folders into the directory into the folder dotfiles.

Now all I need to do is run git add . git commit -m “message” git push -u origin master these commands to push to my Git Repository.

Then I again wanted to automate the above manual process on a weekly basis, so I created a file inside the same dotfiles directory with the name


##!/bin/bashcd ~/dotfilesbash syncfile.shgit add .git commit -m “weekly changes”git push -u origin master -f 

Finally, I created a weekly Cron job with crontab -e

0 0 * * 0 bash /home/ujwal/dotfiles/cronscript.sh


Every week my config files are getting synced automatically and i dont need to remember at all.

There are other great tools for managing dotfiles that have many more features than the above script like https://github.com/jbernard/dotfiles. I simply made my own script as I could learn bash scripting side by side too.