From 07c1d9f590e8de064e9b527c3d425eb898f7e59e Mon Sep 17 00:00:00 2001 From: Stefan Kreutz Date: Mon, 6 Jul 2020 22:40:21 +0200 Subject: Add initial version This commit adds the first published version of the website including the first blog post, Unix Domain Socket Forwarding with OpenSSH. --- _drafts/dotfiles-under-revision-control.md | 83 ++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 _drafts/dotfiles-under-revision-control.md (limited to '_drafts/dotfiles-under-revision-control.md') diff --git a/_drafts/dotfiles-under-revision-control.md b/_drafts/dotfiles-under-revision-control.md new file mode 100644 index 0000000..4cccea3 --- /dev/null +++ b/_drafts/dotfiles-under-revision-control.md @@ -0,0 +1,83 @@ +--- +title: "Dotfiles under revision control" +description: "How I manage my configuration files with Git." +published: 2019-09-02 +--- + + + +I regularly spend some time to fit my preferred tools to my personal need and taste. +Luckily, most command-line tools and a growing number of graphical tools, accept configuration files -- commonly called _dotfiles_ because of the typical dot at the beginnig of the file name, e.g., `.tmux.conf`. +This post describes my not-so-special way to put these dotfiles under revision control using Git and Bash. +In fact, you'll find a myriad of public dotfiles repositories on the web, for example on [GitHub](https://github.com/search?q=dotfiles). + +Add the following snippet to your `~/.bashrc`. +The first line defines a `dotfiles` alias for `git` to distinguish your dotfiles repository from any other Git repository in and below your home directory. +The remaining lines reuse -- you might say hack -- Git's Bash completion for the alias. + +```sh +alias dotfiles="git --git-dir=\${HOME}/.dotfiles/ --work-tree=\${HOME}" +if [ -f /usr/share/git/completion/git-completion.bash ]; then + source /usr/share/git/completion/git-completion.bash + __git_complete dotfiles __git_main +fi +``` + +Initialize a bare Git repository for your dotfiles, and tell Git to ignore untracked files. + +```sh +mkdir ~/.dotfiles +git -C ~/.dotfiles init --bare +dotfiles config status.showUntrackedFiles no +``` + +Now you can `add`, `commit`, and `push` your dotfiles as usual. + +You can even add other repositories as submodules. +The following snippet, for example, adds Vim and Tmux plug-ins for the acclaimed [Solarized](https://ethanschoonover.com/solarized/) color scheme. + +```sh +mkdir -p ~/.tmux/plugins +cd ~/.tmux/plugins +dotfiles submodule add https://github.com/seebi/tmux-colors-solarized.git + +mkdir -p ~/.vim/pack/stefan/{start,opt} +cd ~/.vim/pack/stefan/start +dotfiles submodule add https://github.com/altercation/vim-colors-solarized.git + +dotfiles add ~/gitmodules +``` + +Update the submodules as always. + +```sh +dotfiles submodule update --remote --merge +``` + +Generate help tags. + +```sh +for d in ~/.vim/pack/stefan/*/*/doc; do + vim -u NONE -c "helptags $d" -c q +done +``` + +Finally, clone your dotfiles to another machine. +Be careful to clone into a temporary directory, though. +Otherwise you might screw up your home directory. + +```sh +git clone \ + --recurse-submodules \ + --separate-git-dir=$HOME/.dotfiles \ + example.com:~/git/dotfiles ~/dotfiles-tmp +rm ~/dotfiles-tmp/.git +cp -ai ~/dotfiles-tmp/.* ~ +rm -r ~/dotfiles-tmp +dotfiles config status.showUntrackedFiles no +``` + +That's it. Happy tracking! + +P.S. Did you know that Unix' hidden files were a mistake? +See [this archived post](https://web.archive.org/web/20190318012059/https://plus.google.com/101960720994009339267/posts/R58WgWwN9jp) by Rob Pike. -- cgit v1.2.3