<commit_before>#!/usr/bin/env bash

set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

function update_dotfiles() {
    printf "\nUpdating .dotfiles in $DIR ...\n"
    git -C "$DIR" pull --rebase --autostash
}

function install_brew() {
    if ! which brew >/dev/null; then
        printf "\nInstalling brew ...\n"
        /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    fi
}

function install_ohmyzsh() {
    if [ ! -d ~/.oh-my-zsh ]; then
        printf "\nInstalling .oh-my-zsh ...\n"
        curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh
    fi
}

function install_fish() {
    if ! which fish >/dev/null; then
        printf "\nInstalling fish ...\n"
        $(which brew) install fish
    fi
}

function install_ohmyfish() {
    if [ ! -d "$OMF_PATH" ]; then
        printf "\nInstalling .oh-my-fish ...\n"
        curl -fsSL https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | $(which fish)
    fi
}

function install_vimrc() {
    if [ ! -d ~/.vim_runtime ]; then
        printf "\nInstalling .vimrc ...\n"
        git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
        sh ~/.vim_runtime/install_awesome_vimrc.sh
    else
        printf "\nUpdating .vimrc ...\n"
        git -C ~/.vim_runtime pull --rebase
    fi
}

function install_tmux() {
    if [ ! -d ~/.tmux ]; then
        printf "\nInstalling .tmux ...\n"
        git clone --depth=1 https://github.com/gpakosz/.tmux.git ~/.tmux
    else
        printf "\nUpdating .tmux ...\n"
        git -C ~/.tmux pull --rebase
    fi
    ln -svf ~/.tmux/.tmux.conf ~/.tmux.conf
}

function install_autojump() {
    if ! which autojump >/dev/null; then
        printf "\nInstalling autojump ...\n"
        $(which brew) install autojump
    fi
}

function pre_installs() {
    installs=(
        update_dotfiles
        install_brew
        install_ohmyzsh
        install_fish
        install_ohmyfish
        install_vimrc
        install_tmux
        install_autojump
    )
    for install in "${installs[@]}"; do
        $(expr $install)
    done
}

EXCLUDE_PATTERNS=(".git/" ".DS_Store" "bootstrap.sh" "README.md" "LICENSE")

function sync_dotfiles() {
    printf "\nSyncing dotfiles ...\n"
    rsync $(printf "%s\n" "${EXCLUDE_PATTERNS[@]}" | sed 's/^/--exclude=/g') -avhR --no-perms . ~
}

function link_dotfiles() {
    printf "\nLinking dotfiles ...\n"<commit_msg>Add install tmux<commit_after>#!/usr/bin/env bash

set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

function update_dotfiles() {
    printf "\nUpdating .dotfiles in $DIR ...\n"
    git -C "$DIR" pull --rebase --autostash
}

function install_brew() {
    if ! which brew >/dev/null; then
        printf "\nInstalling brew ...\n"
        /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    fi
}

function install_ohmyzsh() {
    if [ ! -d ~/.oh-my-zsh ]; then
        printf "\nInstalling .oh-my-zsh ...\n"
        curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh
    fi
}

function install_fish() {
    if ! which fish >/dev/null; then
        printf "\nInstalling fish ...\n"
        $(which brew) install fish
    fi
}

function install_ohmyfish() {
    if [ ! -d "$OMF_PATH" ]; then
        printf "\nInstalling .oh-my-fish ...\n"
        curl -fsSL https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | $(which fish)
    fi
}

function install_vimrc() {
    if [ ! -d ~/.vim_runtime ]; then
        printf "\nInstalling .vimrc ...\n"
        git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
        sh ~/.vim_runtime/install_awesome_vimrc.sh
    else
        printf "\nUpdating .vimrc ...\n"
        git -C ~/.vim_runtime pull --rebase
    fi
}

function install_tmux() {
    if ! which tmux >/dev/null; then
        printf "\nInstalling tmux ...\n"
        $(which brew) install tmux
    fi
}

function install_dottmux() {
    if [ ! -d ~/.tmux ]; then
        printf "\nInstalling .tmux ...\n"
        git clone --depth=1 https://github.com/gpakosz/.tmux.git ~/.tmux
    else
        printf "\nUpdating .tmux ...\n"
        git -C ~/.tmux pull --rebase
    fi
    ln -svf ~/.tmux/.tmux.conf ~/.tmux.conf
}

function install_autojump() {
    if ! which autojump >/dev/null; then
        printf "\nInstalling autojump ...\n"
        $(which brew) install autojump
    fi
}

function pre_installs() {
    installs=(
        update_dotfiles
        install_brew
        install_ohmyzsh
        install_fish
        install_ohmyfish
        install_vimrc
        install_tmux
        install_dottmux
        install_autojump
    )
    for install in "${installs[@]}"; do
        $(expr $install)
    done
}

EXCLUDE_PATTERNS=(".git/" ".DS_Store" "bootstrap.sh" "README.md" "LICENSE")

function sync_dotfiles() {
    printf "\nSyncing dotfiles ...\n"
    rsync $(printf "%s\n" "${EXCLUDE_PATTERNS[@]}" | sed 's/^/--exclude=/g') -avhR --no-perms . ~
}

function link_dotfiles() {
    printf "\nLinking dotfiles ...\n"
{'fraction_non_alphanumeric': 0.16064805777864533, 'fraction_numerical': 0.0011711887565879367, 'mean_word_length': 2.1416309012875536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 10, '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': '595101', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1803, 'n_words': 426}