Compare commits
8 Commits
6ffbb1bde2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 97d9ae202a | |||
| b8dc56c275 | |||
|
|
7730f62cde | ||
| fab6b7045f | |||
| 7b5cf4d28c | |||
| fc56e2100f | |||
| bc281476c5 | |||
| 07f6e4c947 |
69
installer/02_git-cli-highlitgh-root.sh
Normal file
69
installer/02_git-cli-highlitgh-root.sh
Normal 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.sh
Normal file
1
installer/04_aliases.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
alias ls="ls --color"
|
||||||
@@ -8,6 +8,13 @@ pause() {
|
|||||||
read -rp "Press Enter to continue..."
|
read -rp "Press Enter to continue..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debmess(){
|
||||||
|
$debdescription="$1"
|
||||||
|
echo "DEBUG MESSAGE: $debdescription"
|
||||||
|
echo "Press enter to continue..."
|
||||||
|
read debmess
|
||||||
|
}
|
||||||
|
|
||||||
select_user() {
|
select_user() {
|
||||||
while true; do
|
while true; do
|
||||||
echo "----------------------------"
|
echo "----------------------------"
|
||||||
@@ -75,8 +82,14 @@ done
|
|||||||
# ========================
|
# ========================
|
||||||
# VARIABLES
|
# VARIABLES
|
||||||
# ========================
|
# ========================
|
||||||
|
|
||||||
|
if [ "$selected_user" == "root" ]; then
|
||||||
|
home="/root"
|
||||||
|
bashrc="$home/.bashrc"
|
||||||
|
else
|
||||||
home="/home/$selected_user"
|
home="/home/$selected_user"
|
||||||
bashrc="$home/.bashrc"
|
bashrc="$home/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
mainfolder="$home/.bashrc.d"
|
mainfolder="$home/.bashrc.d"
|
||||||
neededfolder="$mainfolder/scripts-needed"
|
neededfolder="$mainfolder/scripts-needed"
|
||||||
@@ -91,7 +104,7 @@ script_dir="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
# ========================
|
# ========================
|
||||||
echo "[ Creating folders... ]"
|
echo "[ Creating folders... ]"
|
||||||
|
|
||||||
mkdir -p "$neededfolder"
|
#mkdir -p "$neededfolder"
|
||||||
mkdir -p "$availablefolder"
|
mkdir -p "$availablefolder"
|
||||||
mkdir -p "$enabledfolder"
|
mkdir -p "$enabledfolder"
|
||||||
mkdir -p "$removedfolder"
|
mkdir -p "$removedfolder"
|
||||||
@@ -119,10 +132,11 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ========================
|
# ========================
|
||||||
# COPY MAIN STRUCTURE
|
# COPY NEEDED SCRIPTS
|
||||||
# ========================
|
# ========================
|
||||||
cp -r "$script_dir/../." "$mainfolder"
|
needed_to_copy="$script_dir/scripts-needed"
|
||||||
echo "[ Main folder installed ]"
|
cp -r $needed_to_copy $mainfolder
|
||||||
|
echo "[ Main logic scripts installed ]"
|
||||||
|
|
||||||
# ========================
|
# ========================
|
||||||
# COPY DEFAULT SCRIPTS
|
# COPY DEFAULT SCRIPTS
|
||||||
@@ -132,7 +146,9 @@ echo "[ Installing default scripts... ]"
|
|||||||
default_scripts=(
|
default_scripts=(
|
||||||
"00_default.sh"
|
"00_default.sh"
|
||||||
"01_git-cli-highlitgh.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
|
for script in "${default_scripts[@]}"; do
|
||||||
@@ -148,9 +164,11 @@ done
|
|||||||
# APPLY CHANGES
|
# APPLY CHANGES
|
||||||
# ========================
|
# ========================
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$bashrc"
|
#source "$bashrc"
|
||||||
|
source ~/.bashrc
|
||||||
echo "[ Bashrc reloaded ]"
|
echo "[ Bashrc reloaded ]"
|
||||||
|
|
||||||
|
pause
|
||||||
# ========================
|
# ========================
|
||||||
# FINAL MESSAGE
|
# FINAL MESSAGE
|
||||||
# ========================
|
# ========================
|
||||||
@@ -169,5 +187,3 @@ echo ""
|
|||||||
echo "##################################"
|
echo "##################################"
|
||||||
echo " Thanks for using this script! "
|
echo " Thanks for using this script! "
|
||||||
echo "##################################"
|
echo "##################################"
|
||||||
|
|
||||||
pause
|
|
||||||
|
|||||||
Reference in New Issue
Block a user