Skip to content

Commit

Permalink
Add show notes for Dotfiles Episode 2
Browse files Browse the repository at this point in the history
  • Loading branch information
daviwil committed Jan 24, 2021
1 parent 0a91142 commit 2a50cb0
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions show-notes/Dotfiles-02.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#+title: How to Create a Dotfiles Folder

* Let's create a dotfiles folder!

- Create the folder in the right location
- Move some configuration files into it
- Link them back to the original location
- Verify that it works!

* Create a folder to store your dotfiles

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

#+begin_src sh

mkdir ~/.dotfiles

#+end_src

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=:

#+begin_src sh

mv ~/.emacs.d ~/.dotfiles/
mv ~/.bash_profile ~/.dotfiles

# ... etc ...

#+end_src

You should mirror the directory structure that the 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.

* Create symbolic links to the original config file locations

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

#+begin_src sh

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

#+end_src

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=:

#+begin_src sh

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

#+end_src

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

#+begin_src sh

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

#+end_src

*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 launch an elevated prompt.


* The downside of symbolic links

As you might imagine, it's tedious to create and manage symbolic links like 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!

0 comments on commit 2a50cb0

Please sign in to comment.