commit 27b77f1def3ff264e64a33802a076f2f40b61d8a
parent cb0405971d21c36fb6c1ec97fa4042c44645a318
Author: oscarbenedito <oscar@oscarbenedito.com>
Date:   Sun, 14 Jun 2020 23:51:22 +0200

Added instrucions and aliases to work with new system

Diffstat:
M.config/zsh/aliases | 10++++++++++
MREADME.md | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/.config/zsh/aliases b/.config/zsh/aliases @@ -26,6 +26,16 @@ alias bvw="firefox $HOME/Documents/wiki/build/html/index.html" alias c="git --git-dir=$HOME/.local/share/dotfiles --work-tree=$HOME" alias cv="GIT_DIR=$HOME/.local/share/dotfiles GIT_WORK_TREE=$HOME nvim -c Git -c only" +c-clean() { + rm README.md COPYING + c update-index --skip-worktree README.md COPYING +} + +c-populate() { + c update-index --no-skip-worktree README.md COPYING + c checkout README.md COPYING +} + # Zsh aliases alias -g L="|less" alias -g NULL="> /dev/null 2>&1" diff --git a/README.md b/README.md @@ -2,12 +2,70 @@ This directory hosts some of my dotfiles. It is currently a work in progress. -## Setup +## Working with this repository My solution is based on [this comment][hn-comment] (more info: [1][setup-1], -[2][setup-2]). +[2][setup-2]). A bare repository is initialized on a specified directory +(`$XDG_DATA_HOME/dotfiles` in my case) and then it is used as if it was in the +home directory (using the `--work-tree` option). I have aliased this git command +with options to `c` (see setup below). The `status.showUntrackedFiles no` +setting is used to avoid seeing all files in our home directory. -### Other issues +### Setup + +To start your dotfiles from scratch: + +```sh +git init --bare "$XDG_DATA_HOME/dotfiles" +alias c='/usr/bin/git --git-dir=$XDG_DATA_HOME/dotfiles --work-tree=$HOME' +c config --local status.showUntrackedFiles no +c config --local core.bare false +c config --local core.worktree "$HOME" +c push --set-upstream origin master +c branch --set-upstream-to=origin/master master +``` + +You should put the alias line on your `.zshrc` or `.bashrc`. + +### Cloning + +If you already have a repository and want to set up a new computer: + +```sh +git clone --bare <git-repo-url> "$XDG_DATA_HOME/dotfiles" +alias c='/usr/bin/git --git-dir=$XDG_DATA_HOME/dotfiles --work-tree=$HOME' +c checkout +c config --local status.showUntrackedFiles no +c config --local core.bare false +c config --local core.worktree "$HOME" +c push --set-upstream origin master +c branch --set-upstream-to=origin/master master +``` + +You might need to add the following line to the file +`$XDG_DATA_HOME/dotfiles/config` under the origin master url for git to run +normally, I'm unsure why it doesn't do it by default, I'll investigate some +other time. + +```toml + fetch = +refs/heads/*:refs/remotes/origin/* +``` + +If it gives an error because you already have dotfiles that would be overriden, +you can run the following to put them on a different folder and continue with +the process. You might need to create subfolder for the `mv` to work. + +```sh +mkdir -p dotfiles-backup && \ + c checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \ + xargs -I{} mv {} dotfiles-backup/{} +``` + +## Notes + +I have also created alises `c-clean` and `c-populate` to hide or show the files +`README.md` and `COPYING`. This functions will delete or override the files on +the home directory respectively. On Debian, you might need to change ZSH's syntax highlightning plugin location from `/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh` to