1 minute read

Create a folder to store your dotfiles.

I recommend to creating this directory in the root of your home folder so that it’s easier to use tools like GNU Stow:

The basic of dotfiles
1
mkdir ~/.dotfiles

Now we have a fresh new folder ready to be populated with files!

Move some of your existing configuration files and folders into it

Move the configuration files you care about to an equivalent file path in ~/.dotfiles:

1
2
3
4
5
6
mv ~/.emacs.d ~/.dotfiles/
mv ~/.bash_profile ~/.dotfiles

# ... etc ...

You should mirror the directory structure that files have in your home folder on Linux and MacOs so that dotfiles management tools can easily place the files where they belong.

On Windows this doesn’t matter quite as much.

You can use the ln command on Linux and MacOs to create symbolic links from a source file or directory to a new location:

1
2
# Create a new link called ~/.emacs.d which comes from ~/.dotfiles/.emacs.d
ln -sf ~/.dotfiles/.emacs.d ~/.emacs.d

We’ll use this to create links back into the home directory for all the configuration files and folders we moved.

For Windows users

On Windows, you can create a junction using mklink. To create a link for an individual file, use mklink /H:

1
mklink /H link-name.conf original-file.conf

To create a link for a directory, use mklink /J:

1
mklink /J c:\Users\mbagrat\AppData\Roaming\.emacs.d c:\Users\mbagrat\AppData\Roaming\.dotfiles\.emacs.d

NOTE: this command only works when you have started the Command Prompt (cmd.exe) as an administrator! Make sure to right click the icon and select “Run as Administrator” to lunch an elevated prompt.

As you might imagine, it’s tedious to create and manage symbolic links this, especially when you are syncing them between machines. Some people solve this by writing a “bootstrapping” script that can create all symbolic links automatically. It’s easier to use a tool meant for this purpose, we will talk about GNU Stow and others!

What’s next?

Now that we have a dotfiles folder, the next step is to start managing it with Git!

Resources

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...