<commit_before>#!/bin/bash -e

function displayUsage()
{
    local -r scriptName="$(basename "${BASH_SOURCE[0]}")"

    echo -e "\033[1;33m"
    echo    "SYNOPSIS :"
    echo    "    ${scriptName}"
    echo    "        --help"
    echo    "        --profile-file-name    <PROFILE_FILE_NAME>"
    echo    "        --host-name            <HOST_NAME>"
    echo    "        --users                <USERS>"
    echo -e "\033[1;35m"
    echo    "DESCRIPTION :"
    echo    "    --help                 Help page"
    echo    "    --profile-file-name    Profile file name such as '.profile', '.bash_profile', '.bashrc' (optional)"
    echo    "    --host-name            Custom host name (optional). Default to current host name"
    echo    "    --users                List of users separated by commas or spaces (optional). Default to current user"
    echo -e "\033[1;36m"
    echo    "EXAMPLES :"
    echo    "    ./${scriptName} --help"
    echo    "    ./${scriptName}"
    echo    "    ./${scriptName}"
    echo    "        --users 'user1, user2, user3'"
    echo    "    ./${scriptName}"
    echo    "        --host-name 'my-server.com'"
    echo    "    ./${scriptName}"
    echo    "        --host-name 'my-server.com'"
    echo    "        --users 'user1 user2 user3'"
    echo    "    ./${scriptName}"
    echo    "        --profile-file-name '.bash_profile'"
    echo    "        --host-name 'my-server.com'"
    echo    "        --users 'user1 user2 user3'"
    echo -e "\033[0m"

    exit "${1}"
}

function install()
{
    local -r profileFileName="${1}"
    local -r hostName="${2}"
    local users=(${3//,/ })

    # Reformat PS1

    if [[ "$(isEmptyString "${hostName}")" = 'false' ]]
    then
        PS1_ROOT_PROMPT="$(replaceString "${PS1_ROOT_PROMPT}" '\\h' "${hostName}")"
        PS1_USER_PROMPT="$(replaceString "${PS1_USER_PROMPT}" '\\h' "${hostName}")"
    fi

    # Add Current User To List When Array Is Empty

    if [[ "${#users[@]}" -lt '1' ]]
    then
        users=("$(whoami)")
    fi

    # Update Prompt

    local user=''

    for user in "${users[@]}"
    do
        # Use Auto Detect Profile File Path Or Use Specified Profile File Name

        local profileFilePath
        profileFilePath="$(getProfileFilePath "${user}")"

        if [[ "$(isEmptyString "${profileFileName}")" = 'false' ]]
        then
            profileFilePath="$(getUserHomeFolder "${user}")/${profileFileName}"
        fi

        # Update Profile File Path

        if [[ "$(isEmptyString "${profileFilePath}")" = 'false' ]]
        then
            if [[ "$(whoami)" = "${user}" ]]
            then
                local prompt="export PS1=\"${PS1_ROOT_PROMPT}\""
            else
                local prompt="export PS1=\"${PS1_USER_PROMPT}\""
            fi

            echo -e "Updating '\033[1;32m${profileFilePath}\033[0m'"

            if [[ ! -f "${profileFilePath}" ]]
            then
                touch "${profileFilePath}"
                chown "${user}:${user}" "${profileFilePath}"
            fi

            appendToFileIfNotFound "${profileFilePath}" "${prompt}" "${prompt}" 'false' 'false' 'true'
        else
            warn "WARN : profile '${user}' not found"
        fi
    done

    # Update Default Prompt

    prompt="export PS1=\"${PS1_USER_PROMPT}\""

    appendToFileIfNotFound '/etc/skel/.profile' "${prompt}" "${prompt}" 'false' 'false' 'true'
}

function main()<commit_msg>update PS1<commit_after>#!/bin/bash -e

function displayUsage()
{
    local -r scriptName="$(basename "${BASH_SOURCE[0]}")"

    echo -e "\033[1;33m"
    echo    "SYNOPSIS :"
    echo    "    ${scriptName}"
    echo    "        --help"
    echo    "        --profile-file-name    <PROFILE_FILE_NAME>"
    echo    "        --host-name            <HOST_NAME>"
    echo    "        --users                <USERS>"
    echo -e "\033[1;35m"
    echo    "DESCRIPTION :"
    echo    "    --help                 Help page"
    echo    "    --profile-file-name    Profile file name such as '.profile', '.bash_profile', '.bashrc' (optional)"
    echo    "    --host-name            Custom host name (optional). Default to current host name"
    echo    "    --users                List of users separated by commas or spaces (optional). Default to current user"
    echo -e "\033[1;36m"
    echo    "EXAMPLES :"
    echo    "    ./${scriptName} --help"
    echo    "    ./${scriptName}"
    echo    "    ./${scriptName}"
    echo    "        --users 'user1, user2, user3'"
    echo    "    ./${scriptName}"
    echo    "        --host-name 'my-server.com'"
    echo    "    ./${scriptName}"
    echo    "        --host-name 'my-server.com'"
    echo    "        --users 'user1 user2 user3'"
    echo    "    ./${scriptName}"
    echo    "        --profile-file-name '.bash_profile'"
    echo    "        --host-name 'my-server.com'"
    echo    "        --users 'user1 user2 user3'"
    echo -e "\033[0m"

    exit "${1}"
}

function install()
{
    local -r profileFileName="${1}"
    local -r hostName="${2}"
    local users=(${3//,/ })

    # Reformat PS1

    if [[ "$(isEmptyString "${hostName}")" = 'false' ]]
    then
        PS1_ROOT_PROMPT="$(replaceString "${PS1_ROOT_PROMPT}" '\\h' "${hostName}")"
        PS1_USER_PROMPT="$(replaceString "${PS1_USER_PROMPT}" '\\h' "${hostName}")"
    fi

    # Add Current User To List When Array Is Empty

    if [[ "${#users[@]}" -lt '1' ]]
    then
        users=("$(whoami)")
    fi

    # Update Prompt

    local user=''

    for user in "${users[@]}"
    do
        # Use Auto Detect Profile File Path Or Use Specified Profile File Name

        local profileFilePath
        profileFilePath="$(getProfileFilePath "${user}")"

        if [[ "$(isEmptyString "${profileFileName}")" = 'false' ]]
        then
            profileFilePath="$(getUserHomeFolder "${user}")/${profileFileName}"
        fi

        # Update Profile File Path

        if [[ "$(isEmptyString "${profileFilePath}")" = 'false' ]]
        then
            if [[ "$(whoami)" = "${user}" ]]
            then
                local prompt="export PS1=\"${PS1_ROOT_PROMPT}\""
            else
                local prompt="export PS1=\"${PS1_USER_PROMPT}\""
            fi

            echo -e "Updating '\033[1;32m${profileFilePath}\033[0m'"

            if [[ ! -f "${profileFilePath}" ]]
            then
                touch "${profileFilePath}"
                chown "${user}:${user}" "${profileFilePath}"
            fi

            appendToFileIfNotFound "${profileFilePath}" "${prompt}" "${prompt}" 'false' 'false' 'true'
        else
            warn "WARN : profile '${user}' not found"
        fi
    done

    # Update Default Prompt

    echo -e "Updating '\033[1;32m'/etc/skel/.profile'\033[0m'"

    prompt="export PS1=\"${PS1_USER_PROMPT}\""

    appendToFileIfNotFound '/etc/skel/.profile' "${prompt}" "${prompt}" 'false' 'false' 'true'
}

function main()
{'fraction_non_alphanumeric': 0.164855859771114, 'fraction_numerical': 0.01839779805881501, 'mean_word_length': 1.836483155299918, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3848645', 'n_tokens_mistral': 2208, 'n_tokens_neox': 2082, 'n_words': 528}