<commit_before>#!/usr/bin/env bash
set -e # exit this script if child command exits in error
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOTFILES="$(dirname "$DIR")"

# OS detection
function is_osx() {
  [[ "$OSTYPE" =~ ^darwin ]] || return 1
}
function is_ubuntu() {
  [[ "$(cat /etc/issue 2> /dev/null)" =~ Ubuntu ]] || return 1
}
function is_win() { 
  [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || return 1
}

function get_os() {
  for os in osx ubuntu win; do
    is_$os; [[ $? == ${1:-0} ]] && echo $os
  done
}

function file_list(){
	if is_osx; then
		find "$1" -type f -exec basename {} \;
	else
		find "$1" -mindepth 1 -maxdepth 1 -printf "%P\n"
	fi	
}

function link_files(){
	local dir="$DOTFILES/$1"
	file_list "$dir" | while read -r file; do echo "Will link $dir/$file to $HOME/$file"; "$2 $3" "$dir/$file" "$HOME/$file"; done
}

function unlink_files(){
	local dir="$DOTFILES/$1"
	file_list "$1" | while read -r file; do echo "Will unlink $file to home"; "$2" "$HOME/$file"; done
}

cmd="ln -sfn"
link_files "link" $cmd
#unlink_files "link" "unlink"<commit_msg>making in to function instead<commit_after>#!/usr/bin/env bash
set -e # exit this script if child command exits in error
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOTFILES="$(dirname "$DIR")"

# OS detection
function is_osx() {
  [[ "$OSTYPE" =~ ^darwin ]] || return 1
}
function is_ubuntu() {
  [[ "$(cat /etc/issue 2> /dev/null)" =~ Ubuntu ]] || return 1
}
function is_win() { 
  [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || return 1
}

function get_os() {
  for os in osx ubuntu win; do
    is_$os; [[ $? == ${1:-0} ]] && echo $os
  done
}

function file_list(){
	if is_osx; then
		find "$1" -type f -exec basename {} \;
	else
		find "$1" -mindepth 1 -maxdepth 1 -printf "%P\n"
	fi	
}

function link(){
    ln -sfn "$1" "$2"
}

function copy(){
    cp "$1" "$2"
}

function mod_files(){
	local dir="$DOTFILES/$1"
	file_list "$dir" | while read -r file; do echo "Will link $dir/$file to $HOME/$file"; "$1" "$dir/$file" "$HOME/$file"; done
}

function unlink_files(){
	local dir="$DOTFILES/$1"
	file_list "$1" | while read -r file; do echo "Will unlink $file to home"; "$2" "$HOME/$file"; done
}

mod_files "link"
echo "will cat"
cat ~/.gitconfig
#unlink_files "link" "unlink"
{'fraction_non_alphanumeric': 0.21317157712305027, 'fraction_numerical': 0.016031195840554593, 'mean_word_length': 3.7026476578411405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1026763', 'n_tokens_mistral': 943, 'n_tokens_neox': 893, 'n_words': 275}