added aliases script and root_git_highlight

This commit is contained in:
Simone Cusano
2026-07-19 14:02:41 +01:00
parent fab6b7045f
commit 7730f62cde
4 changed files with 74 additions and 3 deletions

View File

@@ -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

1
installer/04_aliases Normal file
View File

@@ -0,0 +1 @@
alias ls="ls --color"

View File

@@ -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