README.md (6673B) - raw


      1 # Dotfiles
      2 
      3 This directory hosts some of my dotfiles.
      4 
      5 ## Palette
      6 
      7 The colors used on most places are based on the vim onedark theme. They are the
      8 following:
      9 
     10 | Color code | Color   | Color number |
     11 | :--------- | :------ | :----------- |
     12 | 30         | black   | #282c34      |
     13 | 31         | red     | #e06c75      |
     14 | 32         | green   | #98c379      |
     15 | 33         | yellow  | #e5c07b      |
     16 | 34         | blue    | #61afef      |
     17 | 35         | magenta | #c678dd      |
     18 | 36         | cyan    | #56b6c2      |
     19 | 37         | white   | #ffffff      |
     20 
     21 ## Working with this repository
     22 
     23 My solution is based on [this comment][hn-comment] (more info: [1][setup-1],
     24 [2][setup-2]). A bare repository is initialized on a specified directory
     25 (`$XDG_DATA_HOME/dotfiles` in my case) and then it is used as if it was in the
     26 home directory using the `--work-tree` option. I have aliased this git command
     27 with options to `c` (see setup below). The `status.showUntrackedFiles no`
     28 setting is used to avoid seeing all files in the home directory.
     29 
     30 ### Start from scratch
     31 
     32 To start your dotfiles from scratch:
     33 
     34 ```sh
     35 git init --bare "$XDG_DATA_HOME/dotfiles"
     36 alias c='/usr/bin/git --git-dir=$XDG_DATA_HOME/dotfiles --work-tree=$HOME'
     37 c config --local status.showUntrackedFiles no
     38 c config --local core.bare false
     39 c config --local core.worktree "$HOME"
     40 c push --set-upstream origin master
     41 ```
     42 
     43 You should put the alias line on your `.zshrc` or `.bashrc`.
     44 
     45 ### Replicate (method #1)
     46 
     47 If you already have a repository and want to set up a new computer:
     48 
     49 ```sh
     50 git clone --bare <git-repo-url> "$XDG_DATA_HOME/dotfiles"
     51 alias c='/usr/bin/git --git-dir=$XDG_DATA_HOME/dotfiles --work-tree=$HOME'
     52 c checkout
     53 c config --local status.showUntrackedFiles no
     54 c config --local core.bare false
     55 c config --local core.worktree "$HOME"
     56 c push --set-upstream origin master
     57 ```
     58 
     59 You might need to add the following line to the file
     60 `$XDG_DATA_HOME/dotfiles/config` under the origin master url for git to run
     61 normally, I'm unsure why it doesn't do it by default, I'll investigate some
     62 other time.
     63 
     64 ```toml
     65 fetch = +refs/heads/*:refs/remotes/origin/*
     66 ```
     67 
     68 If it gives an error because you already have dotfiles that would be overriden,
     69 you can run the following to put them on a different folder and continue with
     70 the process. You might need to create subfolder for the `mv` to work.
     71 
     72 ```sh
     73 mkdir -p dotfiles-backup && \
     74   c checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
     75   xargs -I{} mv {} dotfiles-backup/{}
     76 ```
     77 
     78 ### Replicate (method #2)
     79 
     80 If you don't care about deleting conflicting dotfiles on your computer, the
     81 following method also works:
     82 
     83 ```sh
     84 git clone --separate-git-dir="$XDG_DATA_HOME/dotfiles" <git-repo-url> dotfiles-tmp
     85 rsync --recursive --verbose --exclude '.git' dotfiles-tmp/ $HOME/
     86 rm --recursive my-dotfiles-tmp
     87 alias c='/usr/bin/git --git-dir=$XDG_DATA_HOME/dotfiles --work-tree=$HOME'
     88 c config --local status.showUntrackedFiles no
     89 c config --local core.worktree "$HOME"
     90 ```
     91 
     92 Run `c status` to make sure everywithing was copied as expected (symlinks will
     93 not). Add the `--ignore-existing` to `rsync` to ignore already existing files,
     94 so you don't override them.
     95 
     96 ### Notes
     97 
     98 I have also created alises `c-clean` and `c-populate` to hide or show the files
     99 `README.md` and `COPYING`. This functions will delete or override the files on
    100 the home directory respectively.
    101 
    102 On Debian, you might need to change ZSH's syntax highlightning plugin location
    103 from `/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh` to
    104 `/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh`.
    105 
    106 ### Other programs you might/will need
    107 
    108 Some of the programs you will need (and some you won't) are the following
    109 (package names for Arch Linux, install with `pacman -S package1 package2 ...`:
    110 
    111 ```
    112 # basic
    113 xf86-video-intel zsh zsh-syntax-highlighting fzf neovim wget man cronie htop sshfs dash pacman-contrib
    114 # xorg
    115 xorg-server xorg-xinit
    116 # utils
    117 xorg-xrandr xorg-xbacklight alsa-utils alsa-lib alsa-plugins xwallpaper xcape xautolock pulseaudio xorg-xsetroot dunst xdotool udisks2 acpi scrot mlocate
    118 # gnome
    119 gnome gnome-extra
    120 # fonts
    121 noto-fonts ttf-font-awesome ttf-dejavu
    122 # software
    123 mpv thunderbird alacritty firefox signal-desktop pass transmission-cli syncthing youtube-dl jq
    124 # other
    125 texlive-most texlive-lang biber gtk2 gtk3 gvfs zathura mupdf zathura-pdf-mupdf pdftk
    126 ```
    127 
    128 and don't forget to install `dwm`, `dmenu`, `slock` and `dwmblocks`:
    129 
    130 ```sh
    131 mkdir -p ~/.local/src
    132 git clone https://git.oscarbenedito.com/dwm ~/.local/src/dwm
    133 git clone https://git.oscarbenedito.com/dmenu ~/.local/src/dmenu
    134 git clone https://git.oscarbenedito.com/slock ~/.local/src/slock
    135 git clone https://git.oscarbenedito.com/dwmblocks ~/.local/src/blocks
    136 sudo make -C ~/.local/src/dwm install
    137 sudo make -C ~/.local/src/dmenu install
    138 sudo make -C ~/.local/src/slock install
    139 sudo make -C ~/.local/src/blocks install
    140 ```
    141 
    142 Also don't forget to put your wallpaper under
    143 `~/.local/share/dwm/wallpaper.png` as well as enable PulseAudio:
    144 
    145 ```
    146 systemctl --user enable pulseaudio.service
    147 ```
    148 
    149 ### Using the files on a server
    150 
    151 If you just want to use a subset of the files (for example in case you want to
    152 use them on a server), you can use `git update-index --skip-worktree file1
    153 file2` to stop tracking files and then delete them. For example, to only use the
    154 files under `.zshenv`, `.config/zsh`, `.config/git`, `.config/nvim` and
    155 `.local/bin/git-head-abbrev`, you could run the following:
    156 
    157 ```
    158 git --git-dir=/root/.local/share/dotfiles --work-tree=/root ls-files | \
    159   sed '/^\.config\/\(zsh\|git\|nvim\)\|^\.zshenv\|^\.local\/bin\/git-head-abbrev/d' | \
    160   xargs git --git-dir=/root/.local/share/dotfiles --work-tree=/root update-index --skip-worktree
    161 git --git-dir=/root/.local/share/dotfiles --work-tree=/root ls-files | \
    162   sed '/^\.config\/\(zsh\|git\|nvim\)\|^\.zshenv\|^\.local\/bin\/git-head-abbrev/d' | \
    163   xargs rm -f
    164 ```
    165 
    166 and add it to a `post-merge` hook. Alternatively, you can use multiple branches,
    167 but I find that more complicated (you'll have to keep merging them).
    168 
    169 ## License
    170 
    171 This repository is licensed under the CC0 1.0 Universal license and therefore is
    172 part of the public domain. To the extent possible under law, Oscar Benedito, who
    173 associated CC0 with this work, has waived all copyright and related or
    174 neighboring rights to this work. You can find a copy of the CC0 license on the
    175 `COPYING` file or [here][license].
    176 
    177 
    178 [hn-comment]: <https://news.ycombinator.com/item?id=11071754>
    179 [setup-1]: <https://www.atlassian.com/git/tutorials/dotfiles>
    180 [setup-2]: <https://www.paritybit.ca/blog/how-i-manage-my-dotfiles>
    181 [license]: <https://creativecommons.org/publicdomain/zero/1.0/>