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

function set_base_dotfiles () {
  declare -a FILES_TO_SYMLINK=(
  # bash stuff
  'aliases'
  'bash_git_completion'
  'bash_logout'
  'bash_profile'
  'bash_prompt'
  'bash_tweaks'
  'bashrc'
  'extra'
  'inputrc'

  # configs
  'editorconfig'
  'gitconfig'
  'hyper.js'
  'tmux.conf'
  'vimrc'
  'vim'
  )
  local sourceDir="$(pwd)"

  # backup any dotfiles that are replaced into ~/dotfiles_old/$backupFolder
  local dotfilesOld="$HOME/dotfiles_old/"
  local backupFolder="$dotfilesOld""backup_$(date "+%Y-%m-%d-%H-%M-%S")"
  # create ~/dotfiles_old if it doesn't exist
  [ -d "$dotfilesOld" ] || mkdir "$dotfilesOld"

  # used inside of the loop
  local sourceFile=''
  local oldFile=''
  local file=''

  # for tracking backups, successes, and failures
  declare -a BACKEDUP_FILES=()
  declare -a SUCCESSFUL_FILES=()
  declare -a FAILED_FILES=()

  echo -e "beginning setup! this will symlink a bunch of dotfiles and back up" \
    "any that are replaced.\n\n"
  for file in ${FILES_TO_SYMLINK[@]}; do
    sourceFile="$sourceDir/$file"
    oldFile="$HOME/.$file"

    [ -f "$oldFile" ] && \
      BACKEDUP_FILES+=("~/.$file") && \
      mv "$oldFile" "$backupFolder"
    if [ -f "$sourceFile" ]; then
      ln -sf $sourceFile $oldFile && \
        SUCCESSFUL_FILES+=("$file") || \
        FAILED_FILES+=("$file")
    else
      FAILED_FILES+=("$file")
    fi
  done
  # log what was backed up, successes, and failures.
  # it's good to reflect.
  [ ${#BACKEDUP_FILES[@]} -ne 0 ] && \
    echo -e "These files were backed up to $backupFolder:" \
      "\n${BACKEDUP_FILES[@]}\n"
  [ ${#SUCCESSFUL_FILES[@]} -ne 0 ] && \
    echo -e "These files were symlinked successfully:\n${SUCCESSFUL_FILES[@]}\n"
  [ ${#FAILED_FILES[@]} -ne 0 ] && \
    echo -e "These files weren't symlinked successfully:" \
      "\n${FAILED_FILES[@]}" && \
    echo -e "Perhaps some of these files were missing from $sourceDir?\n"

  # we can log any files in the dotfiles repo that don't get linked
  declare -a UNLINKED_SOURCEDIR_FILES=()
  local skip<commit_msg>checking for directory too when symlinking<commit_after>#!/usr/bin/env bash

function set_base_dotfiles () {
  declare -a FILES_TO_SYMLINK=(
  # bash stuff
  'aliases'
  'bash_git_completion'
  'bash_logout'
  'bash_profile'
  'bash_prompt'
  'bash_tweaks'
  'bashrc'
  'extra'
  'inputrc'

  # configs
  'editorconfig'
  'gitconfig'
  'hyper.js'
  'tmux.conf'
  'vimrc'
  'vim'
  )
  local sourceDir="$(pwd)"

  # backup any dotfiles that are replaced into ~/dotfiles_old/$backupFolder
  local dotfilesOld="$HOME/dotfiles_old/"
  local backupFolder="$dotfilesOld""backup_$(date "+%Y-%m-%d-%H-%M-%S")"
  # create ~/dotfiles_old if it doesn't exist
  [ -d "$dotfilesOld" ] || mkdir "$dotfilesOld"

  # used inside of the loop
  local sourceFile=''
  local oldFile=''
  local file=''

  # for tracking backups, successes, and failures
  declare -a BACKEDUP_FILES=()
  declare -a SUCCESSFUL_FILES=()
  declare -a FAILED_FILES=()

  echo -e "beginning setup! this will symlink a bunch of dotfiles and back up" \
    "any that are replaced.\n\n"
  for file in ${FILES_TO_SYMLINK[@]}; do
    sourceFile="$sourceDir/$file"
    oldFile="$HOME/.$file"

    [ -f "$oldFile" ] && \
      mv $oldFile $backupFolder  && \
      BACKEDUP_FILES+=("~/.$file")
    if [ -f "$sourceFile" -o -d "$sourceFile" ]; then
      ln -sf $sourceFile $oldFile && \
        SUCCESSFUL_FILES+=("$file") || \
        FAILED_FILES+=("$file")
    else
      FAILED_FILES+=("$file")
    fi
  done
  # log what was backed up, successes, and failures.
  # it's good to reflect.
  [ ${#BACKEDUP_FILES[@]} -ne 0 ] && \
    echo -e "These files were backed up to $backupFolder:" \
      "\n${BACKEDUP_FILES[@]}\n"
  [ ${#SUCCESSFUL_FILES[@]} -ne 0 ] && \
    echo -e "These files were symlinked successfully:\n${SUCCESSFUL_FILES[@]}\n"
  [ ${#FAILED_FILES[@]} -ne 0 ] && \
    echo -e "These files weren't symlinked successfully:" \
      "\n${FAILED_FILES[@]}" && \
    echo -e "Perhaps some of these files were missing from $sourceDir?\n"

  # we can log any files in the dotfiles repo that don't get linked
  declare -a UNLINKED_SOURCEDIR_FILES=()
  local skip
{'fraction_non_alphanumeric': 0.15635411708710137, 'fraction_numerical': 0.0014278914802475012, 'mean_word_length': 3.2368951612903225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1594578', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1500, 'n_words': 399}