<commit_before>#!/bin/bash

# Script for easy setup the dotfiles

# Set some variable
RST="\033[00m"
BY="\033[01;33m"
BW="\033[01;37m"
BR="\033[01;31m"
es="\001"
ee="\002"

function usage() {
    printf "${es}${BW}${ee}Usage: %s [-i] [-d <dotfiles directory absolute path>] args
\n\t${es}${BY}${ee}The script create a symbolic link for all the dotfiles present in the
\tdefault directory path ${es}${BR}${ee}"~/dotfiles"${RST}, ${es}${BY}${ee}unless the "-d" args is used for
\tspecifing another path.
\tInteractively choice which file to link using "-i" args.${RST}\n\n" $0
}

DOTFILES_DIR=${DOTFILES_DIR=~/dotfiles}
DOTFILES="$(find ${DOTFILES_DIR} -maxdepth 1 \
    \( -iname "*.*" \
    -a ! \( -iname ".git" -type d \) \
    -a ! \( -iname "bck" -type d \)\
    -a ! -iname "config.sh" \
    -a ! -iname "README.md" \
    -a ! -iname "LICENSE" \
    -a ! -iname ".gitignore" \
    -a ! -iname ".gitmodules" \) \
    2> /dev/null)"
PLUGINS_DIR=${DOTFILES_DIR}/plugins

while getopts ":d:iph" optname; do
    case "${optname}" in
        "d") DOTFILES_DIR=${OPTARG} ;; 
        "i") INTERACTIVE=true ;; 
        "p") PULL=true ;; 
        "?"|"h"|":") usage
            exit 2;;
    esac
done

if [ ! "${DOTFILES_DIR}" ]; then
    echo "Directory ${DOTFILES_DIR} doesn't exist!"
    exit 1
fi

print_status(){
    [[ $? == 0 ]] && echo -e [${es}${BY}${ee}OK${RST}] || \
        echo -e [${es}${BR}${ee}KO${RST}]
}

create_link() {
    echo -n "Create a symbolic link for the file $(basename $f): "
    ln -s $(basename ${DOTFILES_DIR})/${FILENAME} ../${FILENAME} > /dev/null 2>&1
    print_status
}

make_bck() {
    echo -n "${FILENAME} is a file, make a backup: "
    [[ ! -d ${DOTFILES_DIR}/bck ]] && mkdir ${DOTFILES_DIR}/bck -p
    mv ~/${FILENAME} ${DOTFILES_DIR}/bck/${FILENAME}_$(date +%d%m%Y_%H%M) > /dev/null 2>&1
    print_status
}

pull_submodule() {
    if [ -f "${DOTFILES_DIR}/.gitmodules" ];then
        while true; do
            echo -n "Seems like are present some submodules, would you like to pull"
            echo -n "(yes/no): "<commit_msg>Permit the use of a dotfiles dir name starting with dot<commit_after>#!/bin/bash

# Script for easy setup the dotfiles

# Set some variable
RST="\033[00m"
BY="\033[01;33m"
BW="\033[01;37m"
BR="\033[01;31m"
es="\001"
ee="\002"

function usage() {
    printf "${es}${BW}${ee}Usage: %s [-i] [-d <dotfiles directory absolute path>] args
\n\t${es}${BY}${ee}The script create a symbolic link for all the dotfiles present in the
\tdefault directory path ${es}${BR}${ee}"~/dotfiles"${RST}, ${es}${BY}${ee}unless the "-d" args is used for
\tspecifing another path.
\tInteractively choice which file to link using "-i" args.${RST}\n\n" $0
}

DOTFILES_DIR=${DOTFILES_DIR=~/.dotfiles}
DOTFILES="$(find ${DOTFILES_DIR} -mindepth 1 -maxdepth 1 \
    \( -iname "*.*" \
    -a ! \( -iname ".git" -type d \) \
    -a ! \( -iname "bck" -type d \)\
    -a ! -iname "config.sh" \
    -a ! -iname "README.md" \
    -a ! -iname "LICENSE" \
    -a ! -iname ".gitignore" \
    -a ! -iname ".gitmodules" \) \
    2> /dev/null)"
PLUGINS_DIR=${DOTFILES_DIR}/plugins

while getopts ":d:iph" optname; do
    case "${optname}" in
        "d") DOTFILES_DIR=${OPTARG} ;; 
        "i") INTERACTIVE=true ;; 
        "p") PULL=true ;; 
        "?"|"h"|":") usage
            exit 2;;
    esac
done

if [ ! "${DOTFILES_DIR}" ]; then
    echo "Directory ${DOTFILES_DIR} doesn't exist!"
    exit 1
fi

print_status(){
    [[ $? == 0 ]] && echo -e [${es}${BY}${ee}OK${RST}] || \
        echo -e [${es}${BR}${ee}KO${RST}]
}

create_link() {
    echo -n "Create a symbolic link for the file $(basename $f): "
    ln -sr ${DOTFILES_DIR}/${FILENAME} ~/${FILENAME} > /dev/null 2>&1
    print_status
}

make_bck() {
    echo -n "${FILENAME} is a file, make a backup: "
    [[ ! -d ${DOTFILES_DIR}/bck ]] && mkdir ${DOTFILES_DIR}/bck -p
    mv ~/${FILENAME} ${DOTFILES_DIR}/bck/${FILENAME}_$(date +%d%m%Y_%H%M) > /dev/null 2>&1
    print_status
}

pull_submodule() {
    if [ -f "${DOTFILES_DIR}/.gitmodules" ];then
        while true; do
            echo -n "Seems like are present some submodules, would you like to pull"
            echo -n "(yes/no): "
{'fraction_non_alphanumeric': 0.2082834570265741, 'fraction_numerical': 0.020349533157768735, 'mean_word_length': 2.83302752293578, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 15, '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': '4381913', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1628, 'n_words': 419}