<commit_before>#!/bin/bash
set -euo pipefail
IFS=$'\n\t'


DOTFILES=$(dirname $(readlink -e ${BASH_SOURCE[0]}))


function make:dir () {
    mkdir -p "${HOME}/${1}"
}


function make:link () {
    local SRC="${DOTFILES}/${1}"
    local DST="${HOME}/${2}"
    ln -snf "${SRC}" "${DST}"
}


function setup:vim () {
    make:dir    .vim
    make:link   vim/vimrc       .vim/
    make:link   vim/ftplugin    .vim/
    make:link   vim/snippets    .vim/

    local SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
    local DST="${HOME}/.vim/autoload/plug.vim"
    curl --silent --fail --location\
         --create-dirs --output "${DST}"\
         "${SRC}"
    vim -e +PlugInstall +qa 2>/dev/null || true
}


function main () {
    cd "${DOTFILES}"

    make:dir .cache
    make:dir .config
    make:dir .local/bin

    make:link bash          .config/
    make:link bash/bashrc   .bashrc
    make:link bc            .config/
    make:link firejail      .config/
    make:link fonts         .fonts
    make:link git           .config/
    make:link profile       .profile
    make:link tmux.conf     .tmux.conf
    make:link x/resources   .Xresources

    setup:vim
}

main<commit_msg>Clean old symlinks before setup<commit_after>#!/bin/bash
set -euo pipefail
IFS=$'\n\t'


DOTFILES=$(dirname $(readlink -f ${BASH_SOURCE[0]}))


function make:clean (){
    find ${HOME} -type l -print0 |
        while IFS= read -r -d $'\0' file; do
            if [[ $(readlink -f ${file}) == ${DOTFILES}* ]]; then
                rm -f ${file}
            fi
        done
}


function make:dir () {
    mkdir -p "${HOME}/${1}"
}


function make:link () {
    local SRC="${DOTFILES}/${1}"
    local DST="${HOME}/${2}"
    ln -snf "${SRC}" "${DST}"
}


function setup:vim () {
    make:dir    .vim
    make:link   vim/vimrc       .vim/
    make:link   vim/ftplugin    .vim/
    make:link   vim/snippets    .vim/

    local SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
    local DST="${HOME}/.vim/autoload/plug.vim"
    curl --silent --fail --location\
         --create-dirs --output "${DST}"\
         "${SRC}"
    vim -e +PlugInstall +qa 2>/dev/null || true
}


function main () {
    cd "${DOTFILES}"
    make:clean

    make:dir .cache
    make:dir .config
    make:dir .local/bin

    make:link bash          .config/
    make:link bash/bashrc   .bashrc
    make:link bc            .config/
    make:link firejail      .config/
    make:link fonts         .fonts
    make:link git           .config/
    make:link profile       .profile
    make:link tmux.conf     .tmux.conf
    make:link x/resources   .Xresources

    setup:vim
}

main
{'fraction_non_alphanumeric': 0.1622429906542056, 'fraction_numerical': 0.004485981308411215, 'mean_word_length': 1.9766407119021134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1483317', 'n_tokens_mistral': 1008, 'n_tokens_neox': 932, 'n_words': 218}