惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
T
Tenable Blog
Hugging Face - Blog
Hugging Face - Blog
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
P
Proofpoint News Feed
H
Hacker News: Front Page
P
Privacy & Cybersecurity Law Blog
月光博客
月光博客
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
Forbes - Security
Forbes - Security
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
博客园 - 叶小钗
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
O
OpenAI News
G
Google Developers Blog
Martin Fowler
Martin Fowler
罗磊的独立博客
S
SegmentFault 最新的问题
T
Tor Project blog
量子位

Feed of liolok

Fix Broken URLs of My Site Containerize Steam with systemd-nspawn Containerize Android Studio with systemd-nspawn Run Desktop App with systemd-nspawn Container Oculus Quest 2 Usage Note Set Environment Variables with pam_env Install Arch Linux on Acer Swift 3 SF313-52 Run Mastodon Server on Arch Linux VPS V2Ray Subscription Parse Run SS and MTProxy Server on AWS How to Add Image to Hexo Blog Post Build Blog with Hexo and GitHub Pages
Manage Dotfiles with Git and Stow
2019-09-28 · via Feed of liolok

cd ~{,/zhs/}

I use only git and tons of .gitignore files to manage my dotfiles now, this article is reserved only for reference.

What is Dotfiles

This name came from the dot prefix of file name, for example, your probably most familiar one: ~/.bashrc.

So when we say dotfiles, we’re talking about user level application configuration, which should be stored as text files in ~/.config, according to XDG Base Directory Specification).

However dotfiles may be at anywhere under your home directory: ~/.bashrc, ~/.zshrc, ~/.ssh/config. Apparently, not all apps follow the XDG standard.

Manage for What

  • Filter out your important preferences of application;
  • Backup them to your public or private repository online;
  • Synchronize them between different personal devices;
  • Share configuration tricks with people online.

There may be more benefits, synchronization is considered the most useful one, however.

Control with Git

Git is really powerful also complicated, but in this scene, we start with a quite simple workflow, just initialize a local Git repository right under user’s home directory:

This ~/dotfiles local repository will contain all of app configurations to manage, just as other general Git repositories.

To take control of an app’s configuration, we create a directory for it, then move its dotfile(s) there, keeping the directory structure relative to $HOME.

~/.ssh/config, for example, the dotfile of SSH, let’s move it into our fresh empty repository:

$ mkdir ~/dotfiles/ssh/ && cd ~/dotfiles/ssh/  # make and change to directory for SSH
$ mkdir .ssh/ && cd .ssh/  # keep the directory structre relative to ~/
$ pwd  # now in ~/dotfiles/ssh/.ssh/
$ mv -v ~/.ssh/config .  # move dotfile here

Then comes a set of basic instructions of Git to manage the local repository:

$ cd ~/dotfiles/  # manage repository
$ git add ssh  # track the whole SSH's dotfile directory
$ git commit -m "add ssh"

Now we create an empty repository online, public or private, GitHub / GitLab / other platform / even your self-hosted Git server, it’s your call. Add remote repo’s url to the local one then push.

$ git remote add origin <your-repo-url>
$ git push -u origin master

Deploy with Stow

If you know little about Stow, it’s just a tool that makes symbolic links from ~/dotfiles/<app> to ~/. I rather call this proceed “deploying”, it’s easy and intuitive, just one command in ~/dotfiles/:

$ stow <app1> [<app2> <app3> ...]

So a command like stow bash ssh fontconfig make symbolic links:

  • from ~/dotfiles/bash/.bashrc to ~/.bashrc;
  • from ~/dotfiles/ssh/.ssh/config to ~/.ssh/config;
  • from ~/dotfiles/fontconfig/.config/fontconfig/fonts.conf to ~/.config/fontconfig/fonts.conf.

This is not a reversed instruction to “taking control of app’s dotfiles”,because symbolic links are not moving, they are more like shortcuts. Applications read configuration from symbolic link, while we users could focus on editing in ~/dotfiles.

After a fresh install or some new apps added, we just need to clone or pull the repository, update it to latest version, then choose apps to run stow to deploy, simple and flexible, right?

About --dotfiles Option

This new feature introduced in Stow 2.3.0 preprocesses dot- prefix to real dot, so that users could use ~/dotfiles/bash/dot-bashrc rather than the hidden one.

Up to September of 2019 with version 2.3.1, this feature is still not fully functional with directories like ~/dotfiles/ssh/dot-ssh/, see details in this thread and this thread.

For now, vanilla usage with hidden directories and files is still recommended. Once the bug is fixed, we could use --dotfiles option to use unhidden ones.

Reference