How to Create a Dotfiles Folder
Вставка
- Опубліковано 22 сер 2024
- In this video, I'll show you how you can create a dotfiles folder and move important configuration files there. We'll also learn how to set up symbolic links back to the original file locations so that your programs can find their configuration files. This prepares us to learn how to manage and share our dotfiles with Git in the next episode!
Show notes: github.com/dav...
Check out the previous video "The Basics of Dotfiles" if you haven't already: • The Basics of Dotfiles
My Emacs configuration: github.com/dav...
If you enjoy this series, please consider becoming a sponsor on GitHub or Patreon:
- github.com/spo...
- / systemcrafters
You can also leave a tip via PayPal: paypal.me/daviwil
Follow me on Twitter for more Emacs content!
/ systemcrafters
Chat with the System Crafters community on Discord: / discord
Intro music: Coriolis Effect by logos feat. stefsax, licensed CC-BY
ccmixter.org/fi...
It's surprised me how hard it has been to find a video that simply and clearly explains how to set up the dotfiles repo and get the files linked to the right places. Thanks!
i'm glad i'm not the only one that keeps getting the order of symbolic links mixed up.
That is the next step i need to do, this is very helpful. Two things that stop me are manage dotfiles and Git. Thank you for your videos about manage configuration and also your Emacs videos.
Any plans on continuing the dot files series ? Would love to see how you manage gnu stow.
I'll try to get back to it soon!
When you use "$ ln -sf ~/path symlink", the "~/" part is being translated into a fully qualified / absolute path, e.g. /home/crafter/...
IDK if you want that in every case though (chroots, backup&restore or copying to another system ... other niche use cases).
It would be better to cd to $HOME first, then use relative symlinking, i.e.:
$ ln -sf .dotfiles/.config/mpv .config/mpv
and so forth... but it's a minor point, really. There's nothing "wrong" about the way you do it.
But if you do it the "truely relative" way, nothing can go wrong in any case, no matter what.
Good point, thanks for pointing that out!
@@SystemCrafters Yes, I was confused why he didn't put "/mpv" on the end of that command, because I sure would have. But, it looks like it worked -- like @Paxsali said.
Thanks a lot man, being thinking of something like this for some weeks now
10:00 linux version of ln supports -r flag that helps make relative symlinks; and -T flag for situations like the time stamp when linking should fail instead of creating a symlink at a wrong location.
Hey David, the way I manage my dotfiles is by creating a git bare repository in my home folder and setting an alias like: alias config="/usr/bin/git --git-dir=$HOME/dotfiles/.git/ --work-tree=$HOME"
And then add files to the repository with: config add filename.txt, commit with: config commit, etc. This eliminates the need to create symlinks of all the files
Thanks! I'm planning to cover the bare repository approach in the future, so that was helpful.
@@SystemCrafters You're welcome, loving the videos so far- thank you
I was looking for this, so now I don't need to write this myself. :-)
can you use the bare repository with magit somehow, i also use a bare one and could not yet figure out, who it should work
The order of the arguments of "ln" used to confuse me, too. It helps me to think of them as "cp" and "mv" for the arguments to make sense. ymmv.
That is how I remember the command arguments too. The source(es) are first and last is the destination. It there are many sources, the last must be a directory. Which make it all make sense in mv(1), cp(1) and ln(1).
You have to remember that "ln" can create several links on the same file, so in order for the command to be extensible, the target comes first, then all the created links are listed after.
Very instructive, there will be other videos on this series?
Thanks David!
Thanks! Very cool!
Is there a reason you prefer to create a .dotfiles folder versus creating folders in .config? E.g., a .config/zsh for your .zshrc, etc. Or is it just personal preference?
it keeps your main directory cleaner because you will end up with a lot of dot files and its just basically continuity for every possible dot file you could have. its not a big deal just makes it more parsable for a human and easier to navigate through the CLI.
Edit: i could show a pic of my ~/home/ directory but i'll just put into text the dot files I have, keep in mind im more of a gamer than programmer or practical user of linux.
".steam .minecraft .mozilla .java .local .config" you get the idea, it tends to make your home directory less parsable when you could just have a generalized dotfile folder for all of these.
Edit2: you could also probably simplify your directories further at this point for your configs, so instead of going .config/alacritty/alacritty.yml you could probably just set it up to be .dotfiles/.config/alacritty.yml, but i dont know about that. im just imagining things.
@@bunnysuitlewds126 No, I get it! I just know that some programs already make an entry in ~/.config/ so I've leaned toward exactly as you and the video suggest with moving them, but instead of into a ~/.dotfiles/ folder I've been moving them into ~/.config//
I guess what I was trying to figure out is if the goal is to keep it as clean as possible, if there was some benefit to a ~/.dotfiles/ versus the already-used ~/.config/ I'm assuming there's some reasoning I'm just missing.
Is there any new video related to the topic?
Not yet! I need to get back to this series
@@SystemCrafters Thanks
thank you! very useful! which is the next video?
Why create symbolic links instead of hard links? We would expect that the home folder is contained on a single file system?
That's just the way I've always done it. Are hard links necessary to link across storage devices? If so, I wasn't aware of that!
@@SystemCrafters That the contrary. Hardlinks are basically names pointing to the same content in the file system, so they need to be in the same filesystem. Symlink can cross filesystem, because they are resolved.
Gotcha, so you're saying for the purpose of linking the dotfiles, a hard link would be sufficient. Are there any other benefits? Faster? Don't have to call readlink to resolve?
@@SystemCrafters All the hardlinks on a file *are* the file, there's no assymetry between them, so if you remove one hardlink the others stay valid: there's no such thing as dangling link. For emacs, I don't know if there's a benefit. One cool thing about Emacs, is that when trying to open a symlink, you are asked if you want to open the linked file in the original directory so that e.g. magit can handle it correctly. With hardlinks, you couldn't have such process.
Saved me, thanks
Creating symlink with dired package function is super easy
I haven't tried it yet! What's the command?
@@SystemCrafters M-x dired-do-symlink
Adding details to describe the workflow:
from dired buffer, put cursor on the item to create link for, and invoke dired-do-symlink, it'll ask for link path, navigate, type name for link, and enter. symlink is created.
Thanks ... 😀
why move everything? you could've init a git on $home with --bare flag
Did my previous comment get deleted? :/
I didn't see one come through! I get e-mails for every comment posted on a video and haven't received one for a previous comment of yours. I also checked the "held for review" section for comments and didn't see one there. Maybe UA-cam didn't succeed in posting it to begin with?
@@SystemCrafters No problem. It just happened to me a few times lately in other channels so I began to wonder why. Keep up the good work :)
please make video about Org BRAIN.
I haven't heard of that before! I'll look into it. I will definitely make a video on org-roam which is used for a similar purpose but seemingly less complex
I originally also used org brain, but if you use org-roam with org-roam-server you hav a great way of visualizing your points with a mind map and its connection, which was the main thing i wanted to use org BRAIN for, and org-roam has many other advantages. So i finnaly abandoned Org brain in favor of org-roam (I know its difficult to wrap your mind around org-roam at the beginning and that was the main reason that I did not take a closer look at org-roam for a while, but in the end its better in many ways)
I haven't personally tried Org Brain, but Org Roam is great!
Well, then the man could have made this directory instead, and then it would not have sounded redundant to him:
~/.files
There. It's perfecter than his way.