- Correction de la gestion des couleurs
- Ajout de l information pour la commande alias - debut d'ajot d'alias GIT
This commit is contained in:
parent
319310f86f
commit
fbf7347d89
16
TODO.md
16
TODO.md
|
|
@ -1,9 +1,3 @@
|
||||||
# BUG
|
|
||||||
|
|
||||||
|
|
||||||
> PS1 quand on remonte l historique peut bug
|
|
||||||
> Si bare sur deux ligne bug du couleur fond
|
|
||||||
|
|
||||||
|
|
||||||
# SCRIPT
|
# SCRIPT
|
||||||
- VERIF SI NOM DE L ENV DISPO
|
- VERIF SI NOM DE L ENV DISPO
|
||||||
|
|
@ -15,13 +9,13 @@
|
||||||
- conf nom de machine
|
- conf nom de machine
|
||||||
- menu qui propose des choix
|
- menu qui propose des choix
|
||||||
- faire la connexion git sans faire pass a chaque fois en script
|
- faire la connexion git sans faire pass a chaque fois en script
|
||||||
|
- AJOUTER PLUS D ALIAS
|
||||||
|
- AJOUTER PLUS DE CMD
|
||||||
|
- AJOUTER PLUS DE PATH
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ajouter des alias GIT
|
|
||||||
> mettre le reset
|
|
||||||
|
|
||||||
> git fetch origin
|
|
||||||
> git reset --hard origin/main
|
|
||||||
git clean -fd
|
|
||||||
|
|
||||||
>> rename la machine
|
>> rename la machine
|
||||||
hostnamectl set-hostname gitea
|
hostnamectl set-hostname gitea
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ CMD_LIST_CONFIG_JSON=$(cat <<EOF
|
||||||
{"label": "Network stats", "cmd": "htop", "bin": "htop"}
|
{"label": "Network stats", "cmd": "htop", "bin": "htop"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
"section": "UTILS",
|
||||||
|
"items": [
|
||||||
|
{"label": "Display loaded functions", "cmd": "declare -F"},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,36 @@
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
# SETTING CUSTOM COLOR
|
# ==========================================
|
||||||
NONE="\[\e[0m\]"
|
# 1. COULEURS STANDARDS (Pour echo / scripts)
|
||||||
COLOR_WHITE="\[\e[1;37m\]"
|
# ==========================================
|
||||||
COLOR_GREEN="\[\e[1;32m\]"
|
NONE="\e[0m"
|
||||||
COLOR_RED="\[\e[38;5;196m\]"
|
COLOR_WHITE="\e[1;37m"
|
||||||
COLOR_ORANGE="\[\033[38;5;208m\]"
|
COLOR_GREEN="\e[1;32m"
|
||||||
COLOR_YELLOW="\[\e[1;33m\]"
|
COLOR_RED="\e[38;5;196m"
|
||||||
COLOR_BLUE="\[\e[1;94m\]"
|
COLOR_ORANGE="\033[38;5;208m"
|
||||||
COLOR_CYAN="\[\e[36m\]"
|
COLOR_YELLOW="\e[1;33m"
|
||||||
COLOR_GRAY="\[\e[38;5;250m\]"
|
COLOR_BLUE="\e[1;94m"
|
||||||
COLOR_LIGHT_GREEN="\[\033[38;5;154m\]"
|
COLOR_CYAN="\e[36m"
|
||||||
COLOR_LIGHT_BLUE="\[\033[38;5;31m\]"
|
COLOR_GRAY="\e[38;5;250m"
|
||||||
COLOR_LIGHT_RED="\[\033[01;91m\]"
|
COLOR_LIGHT_GREEN="\033[38;5;154m"
|
||||||
COLOR_DARK_GRAY="\[\033[38;5;239m\]"
|
COLOR_LIGHT_BLUE="\033[38;5;31m"
|
||||||
COLOR_DARK_GREEN="\[\033[38;5;28m\]"
|
COLOR_LIGHT_RED="\033[01;91m"
|
||||||
|
COLOR_DARK_GRAY="\033[38;5;239m"
|
||||||
|
COLOR_DARK_GREEN="\033[38;5;28m"
|
||||||
|
|
||||||
|
# BACKGROUND STANDARDS
|
||||||
|
COLOR_ORANGE_BG="\033[48;5;208m"
|
||||||
|
COLOR_DARK_GREEN_BG="\033[48;5;28m"
|
||||||
|
COLOR_DARK_GRAY_BG="\033[48;5;239m"
|
||||||
|
COLOR_LIGHT_BLUE_BG="\033[48;5;31m"
|
||||||
|
COLOR_LIGHT_RED_BG="\033[01;101m"
|
||||||
|
|
||||||
|
# Fonction pour sécuriser une couleur pour le PS1
|
||||||
|
color_secure() {
|
||||||
|
echo -ne "\[$1\]"
|
||||||
|
}
|
||||||
|
|
||||||
# BACKGROUND
|
|
||||||
COLOR_ORANGE_BG="\[\033[48;5;208m\]"
|
|
||||||
COLOR_DARK_GREEN_BG="\[\033[48;5;28m\]"
|
|
||||||
COLOR_DARK_GRAY_BG="\[\033[48;5;239m\]"
|
|
||||||
COLOR_LIGHT_BLUE_BG="\[\033[48;5;31m\]"
|
|
||||||
COLOR_LIGHT_RED_BG="\[\033[01;101m\]"
|
|
||||||
|
|
||||||
# Les Asci sympas :
|
# Les Asci sympas :
|
||||||
# 🐧 🌀 🍥 ✅ ❎ ❌ ⭕ ℹ️🔄🚨🆔 🆗 🆕 🆙
|
# 🐧 🌀 🍥 ✅ ❎ ❌ ⭕ ℹ️🔄🚨🆔 🆗 🆕 🆙
|
||||||
|
|
@ -5,6 +5,12 @@
|
||||||
#region JSON
|
#region JSON
|
||||||
CONF_LIST_CONFIG_JSON=$(cat <<EOF
|
CONF_LIST_CONFIG_JSON=$(cat <<EOF
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
"section": "SYSTEM",
|
||||||
|
"items": [
|
||||||
|
{"label": "Env vars", "cmd": "/etc/environment"},
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"section": "APACHE",
|
"section": "APACHE",
|
||||||
"items": [
|
"items": [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
function git-reset(){
|
||||||
|
|
||||||
|
local branch
|
||||||
|
|
||||||
|
# Récupère le nom de la branche actuelle
|
||||||
|
branch=$(git branch --show-current 2>/dev/null)
|
||||||
|
[[ -z "$branch" ]] && echo "Pas dans un dépôt Git" && return 1
|
||||||
|
|
||||||
|
git fetch origin
|
||||||
|
git reset --hard origin/"${1:$branch}"
|
||||||
|
git clean -fd
|
||||||
|
|
||||||
|
echo -e "${COLOR_GREEN}✅ Dépôt synchronisé et nettoyé.${NONE}"
|
||||||
|
}
|
||||||
17
inc/alias.sh
17
inc/alias.sh
|
|
@ -28,7 +28,7 @@ alias egrep='egrep --color=auto'
|
||||||
alias fgrep='fgrep --color=auto'
|
alias fgrep='fgrep --color=auto'
|
||||||
alias ports='netstat -tulanp'
|
alias ports='netstat -tulanp'
|
||||||
alias psg='ps aux | grep -i'
|
alias psg='ps aux | grep -i'
|
||||||
alias top='htop'
|
#alias top='htop'
|
||||||
alias cpu='top -o %CPU'
|
alias cpu='top -o %CPU'
|
||||||
alias mem='top -o %MEM'
|
alias mem='top -o %MEM'
|
||||||
alias hdd='ncdu'
|
alias hdd='ncdu'
|
||||||
|
|
@ -44,10 +44,13 @@ alias wlog='tail -fn 100 /var/log/apache2/access.log /var/log/apache2/error.log'
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Shortcut GIT
|
||||||
|
# LOAD GIT FUNCS
|
||||||
|
if [[ -z "${WELCOME_SCRIPT_PATH}" ]]; then
|
||||||
|
WELCOME_SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd)"
|
||||||
|
fi
|
||||||
|
. "${WELCOME_SCRIPT_PATH}/func/git.sh"
|
||||||
|
|
||||||
|
alias gsync='git-reset'
|
||||||
|
#endregion
|
||||||
|
|
||||||
# Frogg version
|
|
||||||
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m\][\[\033[01;91m\]\u\[\033[01;34m\]@\[\033[01;91m\]\h\[\033[01;34m\]]\[\033[01;34m\] \w\[\033[01;37m\] >'
|
|
||||||
# Github https://gist.github.com/justintv/168835
|
|
||||||
#PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \w\[\033[0;32m\]\n$(git branch 2>/dev/null | grep "^*" | colrm 1 2)\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
|
|
||||||
# Mixed version
|
|
||||||
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m\][\[\033[01;91m\]\u\[\033[01;34m\]@\[\033[01;91m\]\h\[\033[01;34m\]]\[\033[01;34m\] \w\[\033[01;37m\] \n$(git branch --show-current 2>/dev/null)\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ fi
|
||||||
|
|
||||||
# Infos
|
# Infos
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${COLOR_YELLOW}Type ${COLOR_WHITE}cmd${COLOR_YELLOW}, ${COLOR_WHITE}conf ${COLOR_YELLOW}or ${COLOR_WHITE}colors ${COLOR_YELLOW}for more information...${NONE}"
|
echo -e "${COLOR_YELLOW}Type ${COLOR_WHITE}cmd${COLOR_YELLOW}, ${COLOR_WHITE}conf${COLOR_YELLOW}, ${COLOR_WHITE}colors ${COLOR_YELLOW}or ${COLOR_WHITE}alias ${COLOR_YELLOW}for more information...${NONE}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
59
inc/ps1.sh
59
inc/ps1.sh
|
|
@ -8,27 +8,9 @@ fi
|
||||||
. "${WELCOME_SCRIPT_PATH}/config/config_colors.sh"
|
. "${WELCOME_SCRIPT_PATH}/config/config_colors.sh"
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
# Frogg version
|
|
||||||
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m[\[\033[01;91m\u\[\033[01;34m@\[\033[01;91m\h\[\033[01;34m]\[\033[01;34m \w\[\033[01;37m >'
|
|
||||||
# Github https://gist.github.com/justintv/168835
|
|
||||||
#PS1='\[\033[0;32m\[\033[0m\033[0;32m\u\[\033[0;36m @ \w\[\033[0;32m\n$(git branch 2>/dev/null | grep "^*" | colrm 1 2)\[\033[0;32m└─\[\033[0m\033[0;32m \$\[\033[0m\033[0;32m\[\033[0m '
|
|
||||||
|
|
||||||
# Mixed version
|
|
||||||
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m[\[\033[01;91m\u\[\033[01;34m@\[\033[01;91m\h\[\033[01;34m]\[\033[01;34m \w\[\033[01;37m \n$(git branch --show-current 2>/dev/null)\[\033[0;32m└─\[\033[0m\033[0;32m \$\[\033[0m\033[0;32m\[\033[0m '
|
|
||||||
|
|
||||||
# ==========================================
|
|
||||||
# CONFIGURATION DES COULEURS (Modifie ici !)
|
|
||||||
# ==========================================
|
|
||||||
|
|
||||||
# Séparateur
|
# Séparateur
|
||||||
SEP="█►"
|
SEP="█►"
|
||||||
|
|
||||||
|
|
||||||
# ==========================================
|
|
||||||
# LOGIQUE DU PROMPT (Ne pas toucher)
|
|
||||||
# ==========================================
|
|
||||||
|
|
||||||
|
|
||||||
get_git_status() {
|
get_git_status() {
|
||||||
local branch status current_bg current_color project upstream behind
|
local branch status current_bg current_color project upstream behind
|
||||||
branch=$(git branch --show-current 2>/dev/null)
|
branch=$(git branch --show-current 2>/dev/null)
|
||||||
|
|
@ -36,35 +18,36 @@ get_git_status() {
|
||||||
|
|
||||||
project=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null)
|
project=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null)
|
||||||
|
|
||||||
# --- SEGMENT PRINCIPAL (PROJET/BRANCHE) ---
|
current_bg="$(color_secure "$COLOR_DARK_GREEN_BG")"
|
||||||
current_bg="$COLOR_DARK_GREEN_BG"
|
current_color="$(color_secure "$COLOR_DARK_GREEN")"
|
||||||
current_color="$COLOR_DARK_GREEN"
|
|
||||||
status="🆗"
|
status="🆗"
|
||||||
|
|
||||||
if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
|
if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
|
||||||
current_bg="$COLOR_LIGHT_RED_BG"
|
current_bg="$(color_secure "$COLOR_LIGHT_RED_BG")"
|
||||||
current_color="$COLOR_LIGHT_RED"
|
# shellcheck disable=SC2086
|
||||||
|
current_color="$(color_secure "$COLOR_LIGHT_RED")"
|
||||||
status="🔄"
|
status="🔄"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Affichage du premier bloc
|
# Affichage du premier bloc
|
||||||
echo -ne "${COLOR_DARK_GRAY}${current_bg}${SEP}$COLOR_WHITE [${project}/${branch}]${status}"
|
echo -ne "$(color_secure "$COLOR_DARK_GRAY")${current_bg}${SEP}$(color_secure "$COLOR_WHITE") [${project}/${branch}]${status}"
|
||||||
|
|
||||||
# --- SEGMENT DYNAMIQUE (BEHIND / PULL) ---
|
# --- SEGMENT DYNAMIQUE (BEHIND / PULL) ---
|
||||||
# On vérifie si on a un upstream (une branche distante)
|
# On vérifie si on a un upstream (une branche distante)
|
||||||
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>/dev/null)
|
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>/dev/null)
|
||||||
if [[ -n "$upstream" ]]; then
|
if [[ -n "$upstream" ]]; then
|
||||||
# On compte le nombre de commits de retard
|
# On compte le nombre de commits de retard
|
||||||
behind=$(git rev-list --count HEAD..$upstream 2>/dev/null)
|
behind=$(git rev-list --count HEAD.."$upstream" 2>/dev/null)
|
||||||
|
|
||||||
if [[ "$behind" -gt 0 ]]; then
|
if [[ "$behind" -gt 0 ]]; then
|
||||||
# Raccord entre le segment précédent et le segment orange
|
# Raccord entre le segment précédent et le segment orange
|
||||||
# On utilise la couleur de fond du précédent pour le texte du SEP
|
# On utilise la couleur de fond du précédent pour le texte du SEP
|
||||||
echo -ne "${current_color}${COLOR_ORANGE_BG}${SEP}$COLOR_WHITE pull $behind 🆙"
|
echo -ne "${current_color}$(color_secure "$COLOR_ORANGE_BG")${SEP}$(color_secure "$COLOR_WHITE") pull $behind 🆙"
|
||||||
|
|
||||||
# On met à jour les variables pour le SEP de fin
|
# On met à jour les variables pour le SEP de fin
|
||||||
current_bg="${COLOR_ORANGE_BG}"
|
# shellcheck disable=SC2086
|
||||||
current_color="${COLOR_ORANGE}"
|
current_bg="$(color_secure $COLOR_ORANGE_BG)"
|
||||||
|
current_color="$(color_secure "$COLOR_ORANGE")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -80,17 +63,17 @@ get_git_status_OK() {
|
||||||
project=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null)
|
project=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null)
|
||||||
|
|
||||||
# Initialisation des couleurs (On utilise des variables propres)
|
# Initialisation des couleurs (On utilise des variables propres)
|
||||||
current_bg="$COLOR_DARK_GREEN_BG"
|
current_bg="$(color_secure "$COLOR_DARK_GREEN_BG")"
|
||||||
current_color="$COLOR_DARK_GREEN"
|
current_color="$(color_secure "$COLOR_DARK_GREEN")"
|
||||||
status="🆗"
|
status="🆗"
|
||||||
|
|
||||||
if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
|
if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
|
||||||
current_bg="$COLOR_LIGHT_RED_BG"
|
current_bg="$(color_secure "$COLOR_LIGHT_RED_BG")"
|
||||||
current_color="$COLOR_LIGHT_RED"
|
current_color="$(color_secure "$COLOR_LIGHT_RED")"
|
||||||
status="🔄"
|
status="🔄"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -ne "${COLOR_DARK_GRAY}${current_bg}${SEP}$COLOR_WHITE TEST[${project}/${branch}]${status}${current_bg}${NONE}${current_color}${SEP}${NONE}"
|
echo -ne "$(color_secure "$COLOR_DARK_GRAY")${current_bg}${SEP}$(color_secure "$COLOR_WHITE") TEST[${project}/${branch}]${status}${current_bg}${NONE}${current_color}${SEP}${NONE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_ps1() {
|
set_ps1() {
|
||||||
|
|
@ -98,10 +81,10 @@ set_ps1() {
|
||||||
EXIT="$?"
|
EXIT="$?"
|
||||||
|
|
||||||
# Segment 1 : User (Bleu) - Ajout des
|
# Segment 1 : User (Bleu) - Ajout des
|
||||||
P1="${COLOR_LIGHT_BLUE_BG}${COLOR_WHITE} <\u@$(hostname -f)>${NONE}"
|
P1="$(color_secure "$COLOR_LIGHT_BLUE_BG")$(color_secure "$COLOR_WHITE") <\u@$(hostname -f)>${NONE}"
|
||||||
|
|
||||||
# Segment 2 : Chemin (Gris) avec raccord Bleu
|
# Segment 2 : Chemin (Gris) avec raccord Bleu
|
||||||
P2="${COLOR_LIGHT_BLUE}${COLOR_DARK_GRAY_BG}${SEP}${COLOR_WHITE} \w"
|
P2="$(color_secure "$COLOR_LIGHT_BLUE")$(color_secure "$COLOR_DARK_GRAY_BG")${SEP}$(color_secure "$COLOR_WHITE") \w"
|
||||||
|
|
||||||
# Segment 3 : Git
|
# Segment 3 : Git
|
||||||
GIT_PART=$(get_git_status)
|
GIT_PART=$(get_git_status)
|
||||||
|
|
@ -110,12 +93,12 @@ set_ps1() {
|
||||||
# On ne met pas d'espace avant ${GIT_PART} car le SEP s'en occupe
|
# On ne met pas d'espace avant ${GIT_PART} car le SEP s'en occupe
|
||||||
PS1="\n${P1}${P2} ${GIT_PART}"
|
PS1="\n${P1}${P2} ${GIT_PART}"
|
||||||
else
|
else
|
||||||
PS1="\n${P1}${P2} ${NONE}${COLOR_DARK_GRAY}${SEP}${NONE}"
|
PS1="\n${P1}${P2} ${NONE}$(color_secure "$COLOR_DARK_GRAY")${SEP}${NONE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ligne 2 : Flèche de retour
|
# Ligne 2 : Flèche de retour
|
||||||
ARROW_C="${COLOR_GREEN}"
|
ARROW_C="$(color_secure "$COLOR_GREEN")"
|
||||||
[[ $EXIT != 0 ]] && ARROW_C="${COLOR_LIGHT_RED}"
|
[[ $EXIT != 0 ]] && ARROW_C="$(color_secure "$COLOR_LIGHT_RED")"
|
||||||
|
|
||||||
PS1+="\n${ARROW_C}└─${NONE} "
|
PS1+="\n${ARROW_C}└─${NONE} "
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue