diff --git a/installer/02_git-cli-highlitgh-root.sh b/installer/02_git-cli-highlitgh-root.sh new file mode 100644 index 0000000..38aa154 --- /dev/null +++ b/installer/02_git-cli-highlitgh-root.sh @@ -0,0 +1,69 @@ +parse_git_branch() { + if git rev-parse --is-inside-work-tree &>/dev/null; then + + status_output=$(git status --porcelain --branch 2>/dev/null) + + branch=$(echo "$status_output" | head -n1 | sed -E 's/^## ([^ .]+).*/\1/') + ahead=$(echo "$status_output" | grep -o 'ahead [0-9]*' | awk '{print $2}') + behind=$(echo "$status_output" | grep -o 'behind [0-9]*' | awk '{print $2}') + + staged=$(echo "$status_output" | grep -E '^[A-Z]' | wc -l) + modified=$(echo "$status_output" | grep -E '^.[A-Z]' | wc -l) + untracked=$(echo "$status_output" | grep -E '^\?\?' | wc -l) + + GREEN_BOLD="\[\033[1;32m\]" + PURPLE_BOLD="\[\033[1;35m\]" + YELLOW_BOLD="\[\033[1;33m\]" + RED_BOLD="\[\033[1;31m\]" + CYAN_BOLD="\[\033[1;36m\]" + RESET="\[\033[0m\]" + + git_status="" + + [ "$staged" -gt 0 ] && git_status="${git_status}${GREEN_BOLD}+${staged}${RESET} " + [ "$modified" -gt 0 ] && git_status="${git_status}${YELLOW_BOLD}M:${modified}${RESET} " + [ "$untracked" -gt 0 ] && git_status="${git_status}${RED_BOLD}N:${untracked}${RESET} " + + remote_status="" + [ -n "$ahead" ] && remote_status="${remote_status}${CYAN_BOLD}↑${ahead}${RESET}" + [ -n "$behind" ] && remote_status="${remote_status}${CYAN_BOLD}↓${behind}${RESET}" + + if [ "$staged" -eq 0 ] && [ "$modified" -eq 0 ] && [ "$untracked" -eq 0 ]; then + branch_display="${GREEN_BOLD}${branch}${RESET}" + else + branch_display="${PURPLE_BOLD}${branch}${RESET}" + fi + + output="(${branch_display}" + [ -n "$remote_status" ] && output="${output} ${remote_status}" + [ -n "$git_status" ] && output="${output} ${git_status}" + + output=$(echo "$output" | sed 's/ $//') + output="${output})" + + printf "%s" "$output" + fi +} + +# 🎨 Palette +RED_DARK="\[\033[1;31m\]" # bold +RED_LIGHT="\[\033[1;91m\]" # bold +WHITE="\[\033[0;37m\]" # NON bold +YELLOW="\[\033[0;33m\]" # NON bold +PURPLE="\[\033[1;35m\]" # bold +GREEN="\[\033[1;32m\]" +BLUE="\[\033[1;34m\]" +RESET="\[\033[0m\]" +YELLOW_LIGHT="\[\033[0;93m\]" + +set_prompt() { + if [ "$EUID" -eq 0 ]; then + # ☠️ ROOT + PS1="${RED_DARK}\u${RESET}${WHITE}@${RED_LIGHT}\h${RESET}:${YELLOW_LIGHT}\w${RESET}$(parse_git_branch) ${PURPLE}#${RESET} " + else + # 👤 USER + PS1="${GREEN}\u${RESET}@${BLUE}\h${RESET}:${PURPLE}\w${RESET}$(parse_git_branch) ${BLUE}>${RESET} " + fi +} + +PROMPT_COMMAND=set_prompt diff --git a/installer/02_bashboard.sh b/installer/03_bashboard.sh similarity index 100% rename from installer/02_bashboard.sh rename to installer/03_bashboard.sh diff --git a/installer/04_aliases b/installer/04_aliases new file mode 100644 index 0000000..5000731 --- /dev/null +++ b/installer/04_aliases @@ -0,0 +1 @@ +alias ls="ls --color" diff --git a/installer/brc-script-install.sh b/installer/brc-script-install.sh index 9b72be3..08cdc22 100755 --- a/installer/brc-script-install.sh +++ b/installer/brc-script-install.sh @@ -140,7 +140,9 @@ echo "[ Installing default scripts... ]" default_scripts=( "00_default.sh" "01_git-cli-highlitgh.sh" - "02_bashboard.sh" + "02_git-cli-highlitgh-root.sh" + "03_bashboard.sh" + "04_aliases" ) for script in "${default_scripts[@]}"; do @@ -160,6 +162,7 @@ done source ~/.bashrc echo "[ Bashrc reloaded ]" +pause # ======================== # FINAL MESSAGE # ======================== @@ -178,5 +181,3 @@ echo "" echo "##################################" echo " Thanks for using this script! " echo "##################################" - -pause \ No newline at end of file