<commit_before>#!/bin/bash

BASH_DIR=$HOME/.bash
PLIST=$BASH_DIR/my-config-plist
PROFILE=$BASH_DIR/my-config.sh

#format the script name for a user friendly package name
__format_script_name(){
        echo ${1%.*} | sed 's/^.*-//'
}

__verbosity(){
   if [ "$1" == "on" ]; then
        export MY_CONFIG_VERBOSE=1;
    else
        export MY_CONFIG_VERBOSE=0;
   fi
}

__log(){
  if [ "$MY_CONFIG_VERBOSE" == "1" ]; then
      echo "$1"
  fi
}

#load and export any variable in a configuration file
 __load_config_file(){
    local configfile=$1
    local configfile_secured='/tmp/$(__random).cfg'

    # check if the file contais something we don't want
    if egrep -q -v '^#|^[^ ]*=[^;]*' "$configfile"; then
      __log "Config file is unclean, cleaning it..." >&2
      egrep '^#|^[^ ]*=[^;&]*'  "configfile" > "configfile_secured"
      configfile="$configfile_secured"
    fi

 #   typeset -a config #init array
 #   config=( #set default values
 #         [host]="teste"
 #         [host2]="teste2"
 #     )

    while read line || [ -n "$line" ]
    do
      if echo $line | grep -F = &>/dev/null
      then
        varname=$(echo "$line" | cut -d '=' -f 1)
        export $varname=$(echo "$line" | cut -d '=' -f 2-)
      fi
    done < "$configfile"
}

#useful which will give you the full directory name of the script no matter where it is being called
#from including any combination of aliases, source, bash -c, symlinks, etc..
__current_location(){
    SOURCE="${BASH_SOURCE[0]}"
    while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
        DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
        SOURCE="$(readlink "$SOURCE")"
        [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    done
    echo "$( cd -P "$( dirname "$SOURCE" )" && pwd )"
}

#generate a random value
__random(){
	echo $(cat /dev/urandom | base64 | tr -dc A-Za-z0-9_ | head -c8)
}

#exit script
__abort(){
  __log $1
  exit 1
}

__exit(){
  __log $1
  exit 0
}

__is_mac(){
   if [[ "$OSTYPE" == "darwin"* ]]; then
     echo 1;
   else
     echo 0;
   fi
}

__is_linux(){
	if [[ "$OSTYPE" == "linux-gnu" ]]; then
    		echo 1;
	else
		echo 0;
	fi
}

__exists(){
	type -P $1 &>/dev/null && echo 1 || echo 0;

}

__my_env(){

	if [ $# -eq 1 ]; then
    echo $1 >> $PROFILE
    return
  fi

  if [ $(__is_mac) == "1" ]; then
    #defaults write /Users/Pedro/.MacOSX/environment.plist PYTHONPATH -string "/usr/local/lib/python2.7/site-packages"
    echo setenv $1 $2 >> $PLIST
		if [ $(__exists launchctl) == "1"  ]; then
	  	launchctl setenv $1 $2
		fi

	fi
	export $1=$2
	echo export $1=$2 >> $PROFILE
}

__my_alias(){
  if [[ ! $# -eq 2  ]]; then
    __log "You need to pass two parameters."
    exit
  fi

  echo alias $1=\'$2\' >> ~/.bash/.bash_aliases

}

__my_link(){
  echo ln -s $1 $2
}

__my_sync(){
  SOURCE=$(echo "'$1'" | sed 's/~\//\/home\//g')
  SOURCE=$sync_folder$SOURCE
  local TARGET
  if [[ $# -eq 1 ]]; then
    TARGET="$1"
  else
    TARGET="$2"
  fi
  echo $SOURCE
  __my_link $SOURCE $TARGET
}

__my_path_remove(){
	local IFS=':'
        local NEWPATH
        local DIR
        local PATHVARIABLE=${2:-PATH}
        for DIR in ${!PATHVARIABLE} ; do
                if [ "$DIR" != "$1" ] ; then
                  NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
                fi
        done
        export $PATHVARIABLE="$NEWPATH"<commit_msg>Fix sync action behavior<commit_after>#!/bin/bash

BASH_DIR=$HOME/.bash
PLIST=$BASH_DIR/my-config-plist
PROFILE=$BASH_DIR/my-config.sh

#format the script name for a user friendly package name
__format_script_name(){
        echo ${1%.*} | sed 's/^.*-//'
}

__verbosity(){
   if [ "$1" == "on" ]; then
        export MY_CONFIG_VERBOSE=1;
    else
        export MY_CONFIG_VERBOSE=0;
   fi
}

__log(){
  if [ "$MY_CONFIG_VERBOSE" == "1" ]; then
      echo "$1"
  fi
}

#load and export any variable in a configuration file
 __load_config_file(){
    local configfile=$1
    local configfile_secured='/tmp/$(__random).cfg'

    # check if the file contais something we don't want
    if egrep -q -v '^#|^[^ ]*=[^;]*' "$configfile"; then
      __log "Config file is unclean, cleaning it..." >&2
      egrep '^#|^[^ ]*=[^;&]*'  "configfile" > "configfile_secured"
      configfile="$configfile_secured"
    fi

 #   typeset -a config #init array
 #   config=( #set default values
 #         [host]="teste"
 #         [host2]="teste2"
 #     )

    while read line || [ -n "$line" ]
    do
      if echo $line | grep -F = &>/dev/null
      then
        varname=$(echo "$line" | cut -d '=' -f 1)
        export $varname=$(echo "$line" | cut -d '=' -f 2-)
      fi
    done < "$configfile"
}

#useful which will give you the full directory name of the script no matter where it is being called
#from including any combination of aliases, source, bash -c, symlinks, etc..
__current_location(){
    SOURCE="${BASH_SOURCE[0]}"
    while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
        DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
        SOURCE="$(readlink "$SOURCE")"
        [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
    done
    echo "$( cd -P "$( dirname "$SOURCE" )" && pwd )"
}

#generate a random value
__random(){
	echo $(cat /dev/urandom | base64 | tr -dc A-Za-z0-9_ | head -c8)
}

#exit script
__abort(){
  __log $1
  exit 1
}

__exit(){
  __log $1
  exit 0
}

__is_mac(){
   if [[ "$OSTYPE" == "darwin"* ]]; then
     echo 1;
   else
     echo 0;
   fi
}

__is_linux(){
	if [[ "$OSTYPE" == "linux-gnu" ]]; then
    		echo 1;
	else
		echo 0;
	fi
}

__exists(){
	type -P $1 &>/dev/null && echo 1 || echo 0;

}

__my_env(){

	if [ $# -eq 1 ]; then
    echo $1 >> $PROFILE
    return
  fi

  if [ $(__is_mac) == "1" ]; then
    #defaults write /Users/Pedro/.MacOSX/environment.plist PYTHONPATH -string "/usr/local/lib/python2.7/site-packages"
    echo setenv $1 $2 >> $PLIST
		if [ $(__exists launchctl) == "1"  ]; then
	  	launchctl setenv $1 $2
		fi

	fi
	export $1=$2
	echo export $1=$2 >> $PROFILE
}

__my_alias(){
  if [[ ! $# -eq 2  ]]; then
    __log "You need to pass two parameters."
    exit
  fi

  echo alias $1=\'$2\' >> ~/.bash/.bash_aliases

}

__my_link(){
  ln -s $1 $2
}

__my_sync(){
  SOURCE=${1//$HOME/"/home"}
  SOURCE=$sync_folder$SOURCE
  local TARGET
  if [[ $# -eq 1 ]]; then
    TARGET="$1"
  else
    TARGET="$2"
  fi
  __my_link $SOURCE $TARGET
}

__my_path_remove(){
	local IFS=':'
        local NEWPATH
        local DIR
        local PATHVARIABLE=${2:-PATH}
        for DIR in ${!PATHVARIABLE} ; do
                if [ "$DIR" != "$1" ] ; then
                  NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
                fi
        done
        export $PATHVARIABLE="$NEWPATH"
{'fraction_non_alphanumeric': 0.16803574002017582, 'fraction_numerical': 0.01556420233463035, 'mean_word_length': 2.505050505050505, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '7082286', 'n_tokens_mistral': 2636, 'n_tokens_neox': 2507, 'n_words': 738}