<commit_before>#!/bin/sh

# constants

log_file=$(basename "$0.log")
vim_bundle_dir=$HOME/.vim/bundle
github_address=https://github.com


# functions

message() {
  echo "$@" >&2
}

fail() {
  message "$@"
  exit 1
}

install_ghq() {
  go get github.com/motemen/ghq
}

install_peco() {
  go get github.com/peco/peco/cmd/peco
}

install_vundle() {
  vundle_dir=$vim_bundle_dir/Vundle.vim

  if ! [ -d "$vundle_dir/.git" ]
  then
    mkdir -p "$vundle_dir" &&
    git clone "$github_address/VundleVim/Vundle.vim" "$vundle_dir"
  fi
}

install_youcompleteme() {
  ycm=YouCompleteMe
  ycm_dir="$vim_bundle_dir/$ycm"

  mkdir -p "$ycm_dir" &&
  (
    cd "$ycm_dir" &&
    if ! [ -d .git ]
    then
      git clone "$github_address/Valloric/$ycm" .
    fi &&
    git submodule update --init --recursive &&
    ./install.py
  )
}

install_vim_plugins() {
  install_vundle &&
  install_youcompleteme &&
  vim +PluginInstall +qall
}

install_antizen() {
  antigen_dir=$HOME/.antigen

  if ! [ -d "$antigen_dir" ]
  then
    git clone "$github_address/zsh-users/antigen.git" "$antigen_dir"
  fi
}

install_zsh_plugins() {
  install_antizen &&
  zsh $HOME/.local/bin/install_zsh_plugins.zsh
}

install_fzf() {
  fzf_repo=junegunn/fzf

  ghq get $fzf_repo &&
  yes | ${GHQ_ROOT:-$HOME/.ghq}/github.com/$fzf_repo/install --no-update-rc
}

check_args() {
  if [ $# -ne 0 ]
  then
    fail "usage: $(basename $0)"
  fi
}

check_old_log_file() {
  if [ -f "$log_file" ]
  then
    fail "Log file, \"$log_file\" already exists. Delete it and rerun me."
  fi
}


# main routine

check_args "$@"
check_old_log_file

(
  . $HOME/.profile &&

  install_zsh_plugins &&
  install_ghq &&
  install_peco &&
  install_fzf &&
  install_vim_plugins
) 2> $log_file

if [ $? -ne 0 ]
then
  fail "Failed to initialize dotfiles environment." \
       "See $log_file for troubleshooting."<commit_msg>Install linuxbrew only on Linux<commit_after>#!/bin/sh

# constants

log_file=$(basename "$0.log")
vim_bundle_dir=$HOME/.vim/bundle
github_address=https://github.com


# functions

message() {
  echo "$@" >&2
}

fail() {
  message "$@"
  exit 1
}

install_linuxbrew() {
  git clone $github_address/Linuxbrew/linuxbrew.git $HOME/.linuxbrew
}

install_ghq() {
  go get github.com/motemen/ghq
}

install_peco() {
  go get github.com/peco/peco/cmd/peco
}

install_vundle() {
  vundle_dir=$vim_bundle_dir/Vundle.vim

  if ! [ -d "$vundle_dir/.git" ]
  then
    mkdir -p "$vundle_dir" &&
    git clone "$github_address/VundleVim/Vundle.vim" "$vundle_dir"
  fi
}

install_youcompleteme() {
  ycm=YouCompleteMe
  ycm_dir="$vim_bundle_dir/$ycm"

  mkdir -p "$ycm_dir" &&
  (
    cd "$ycm_dir" &&
    if ! [ -d .git ]
    then
      git clone "$github_address/Valloric/$ycm" .
    fi &&
    git submodule update --init --recursive &&
    ./install.py
  )
}

install_vim_plugins() {
  install_vundle &&
  install_youcompleteme &&
  vim +PluginInstall +qall
}

install_antizen() {
  antigen_dir=$HOME/.antigen

  if ! [ -d "$antigen_dir" ]
  then
    git clone "$github_address/zsh-users/antigen.git" "$antigen_dir"
  fi
}

install_zsh_plugins() {
  install_antizen &&
  zsh $HOME/.local/bin/install_zsh_plugins.zsh
}

install_fzf() {
  fzf_repo=junegunn/fzf

  ghq get $fzf_repo &&
  yes | ${GHQ_ROOT:-$HOME/.ghq}/github.com/$fzf_repo/install --no-update-rc
}

check_args() {
  if [ $# -ne 0 ]
  then
    fail "usage: $(basename $0)"
  fi
}

check_old_log_file() {
  if [ -f "$log_file" ]
  then
    fail "Log file, \"$log_file\" already exists. Delete it and rerun me."
  fi
}


# main routine

check_args "$@"
check_old_log_file

(
  . $HOME/.profile &&

  if on_linux
  then
    install_linuxbrew
  fi

  install_zsh_plugins &&
  install_ghq &&
  install_peco &&
  install_fzf &&
  install_vim_plugins
) 2> $log_file

if [ $? -ne 0 ]
then
  fail "Failed to initialize dotfiles environment." \
       "See $log_file for troubleshooting."
{'fraction_non_alphanumeric': 0.1496790757381258, 'fraction_numerical': 0.003594351732991014, 'mean_word_length': 3.1982758620689653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '473740', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1568, 'n_words': 293}