<commit_before>#!/usr/bin/env bash
set -o errexit -o errtrace -o pipefail -o noclobber -o nounset
IFS=$'\n\t'

install_dir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $install_dir
CONF_HOME=${XDG_CONFIG_HOME:-${HOME}/.config}

bindir=$HOME/local/bin
srcdir=$HOME/local/src

function install_zsh_syntax_highlighting() {
  local zsh_git_dir="$CONF_HOME/zsh/zsh-syntax-highlighting"
  [ -d $zsh_git_dir ] && rm -rf $zsh_git_dir
  if [ $op_uninstall -eq 1 ]; then
    echo Uninstalled zsh_syntax_highlighting
    return 0
  fi

  echo 'Installing zsh-syntax-highlighting... '
  local zsh_git_repo='https://github.com/zsh-users/zsh-syntax-highlighting.git'

  git clone --depth 1 $zsh_git_repo $zsh_git_dir 2>&1
  echo "########"
  echo
}

function install_neovim() {
  # Cleanup previous install
  [ -f $bindir/nvim ] && rm $bindir/nvim
  [ -f $bindir/nvim.appimage ] && rm $bindir/nvim.appimage
  [ -f $srcdir/squashfs-root-nvim ] && rm -r $srcdir/squashfs-root-nvim
  [ $op_uninstall -eq 1 ] && echo 'Uninstalled neovim'
  [ $op_uninstall -eq 1 ] && return 0

  echo 'Installing neovim... '
  # get exe, test if appimage can open, otherwise extract.
  [ $op_unstable -eq 1 ] && tag='nightly' || tag='stable'
  nvim_file="nvim.appimage"
  nvim_url="https://github.com/neovim/neovim/releases/download/${tag}/nvim.appimage"
  wget -O $nvim_file $nvim_url
  chmod 755 $nvim_file
  # if it doesn't execute, extract the file
  mkdir -p $bindir
  if ! ./$nvim_file --noplugin -u NONE +q > /dev/null 2>&1; then
    [ -f squashfs-root ] && rm -rfI squashfs-root
    ./$nvim_file --appimage-extract
    mv squashfs-root $srcdir/squashfs-root-nvim
    ln -s $srcdir/squashfs-root-nvim/usr/bin/nvim $bindir/nvim
  else  # if it does, just plop it in the bin dir
    version=$(./$nvim_file --version | head -n1 | cut -f2 -d' ')
    mv $nvim_file $bindir/$nvim_file-$version
    ln -sf $bindir/$nvim_file-$version $bindir/nvim
  fi

}

function install_python_via_conda() {
  local ext=$(lscpu | grep 'CPU op-mode' | grep -q 64-bit && echo '_64.sh' || echo '.sh')
  if [ "$(uname)" = 'Linux' ]; then
    local fname=Miniconda3-4.5.12-Linux-x86$ext
  else
    local fname=Miniconda3-4.5.12-MacOSX-x86$ext
  fi
  local url=https://repo.anaconda.com/miniconda/$fname
  wget $url -O $fname
  bash $fname
  source deactivate
  conda install python pip
  pip install --upgrade pip
  pip install --upgrade pynvim
  rm $fname
}

function install_fzf() {
  local fzf_git_dir="$srcdir/fzf"
  if [ $op_uninstall -eq 1 ]; then
    [ command -v fzf > /dev/null 2>&1 ] || return 0
    for f in $fzf_git_dir/bin/*; do
      rm $bindir/$(basename $f) $f
    done
    rm -rf $fzf_git_dir
    echo Uninstalled fzf
    return 0<commit_msg>Update miniconda3 to latest<commit_after>#!/usr/bin/env bash
set -o errexit -o errtrace -o pipefail -o noclobber -o nounset
IFS=$'\n\t'

install_dir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $install_dir
CONF_HOME=${XDG_CONFIG_HOME:-${HOME}/.config}

bindir=$HOME/local/bin
srcdir=$HOME/local/src

function install_zsh_syntax_highlighting() {
  local zsh_git_dir="$CONF_HOME/zsh/zsh-syntax-highlighting"
  [ -d $zsh_git_dir ] && rm -rf $zsh_git_dir
  if [ $op_uninstall -eq 1 ]; then
    echo Uninstalled zsh_syntax_highlighting
    return 0
  fi

  echo 'Installing zsh-syntax-highlighting... '
  local zsh_git_repo='https://github.com/zsh-users/zsh-syntax-highlighting.git'

  git clone --depth 1 $zsh_git_repo $zsh_git_dir 2>&1
  echo "########"
  echo
}

function install_neovim() {
  # Cleanup previous install
  [ -f $bindir/nvim ] && rm $bindir/nvim
  [ -f $bindir/nvim.appimage ] && rm $bindir/nvim.appimage
  [ -f $srcdir/squashfs-root-nvim ] && rm -r $srcdir/squashfs-root-nvim
  [ $op_uninstall -eq 1 ] && echo 'Uninstalled neovim'
  [ $op_uninstall -eq 1 ] && return 0

  echo 'Installing neovim... '
  # get exe, test if appimage can open, otherwise extract.
  [ $op_unstable -eq 1 ] && tag='nightly' || tag='stable'
  nvim_file="nvim.appimage"
  nvim_url="https://github.com/neovim/neovim/releases/download/${tag}/nvim.appimage"
  wget -O $nvim_file $nvim_url
  chmod 755 $nvim_file
  # if it doesn't execute, extract the file
  mkdir -p $bindir
  if ! ./$nvim_file --noplugin -u NONE +q > /dev/null 2>&1; then
    [ -f squashfs-root ] && rm -rfI squashfs-root
    ./$nvim_file --appimage-extract
    mv squashfs-root $srcdir/squashfs-root-nvim
    ln -s $srcdir/squashfs-root-nvim/usr/bin/nvim $bindir/nvim
  else  # if it does, just plop it in the bin dir
    version=$(./$nvim_file --version | head -n1 | cut -f2 -d' ')
    mv $nvim_file $bindir/$nvim_file-$version
    ln -sf $bindir/$nvim_file-$version $bindir/nvim
  fi

}

function install_python_via_conda() {
  local ext=$(lscpu | grep 'CPU op-mode' | grep -q 64-bit && echo '_64.sh' || echo '.sh')
  if [ "$(uname)" = 'Linux' ]; then
    local fname=Miniconda3-latest-Linux-x86$ext
  else
    local fname=Miniconda3-latest-MacOSX-x86$ext
  fi
  local url=https://repo.anaconda.com/miniconda/$fname
  wget $url -O $fname
  bash $fname
  source deactivate
  conda install python pip
  pip install --upgrade pip
  pip install --upgrade pynvim
  rm $fname
}

function install_fzf() {
  local fzf_git_dir="$srcdir/fzf"
  if [ $op_uninstall -eq 1 ]; then
    [ command -v fzf > /dev/null 2>&1 ] || return 0
    for f in $fzf_git_dir/bin/*; do
      rm $bindir/$(basename $f) $f
    done
    rm -rf $fzf_git_dir
    echo Uninstalled fzf
    return 0
{'fraction_non_alphanumeric': 0.14862385321100918, 'fraction_numerical': 0.013394495412844036, 'mean_word_length': 3.2786499215070646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5575775', 'n_tokens_mistral': 2309, 'n_tokens_neox': 2182, 'n_words': 512}