-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc_configuracion.sh
More file actions
executable file
·71 lines (56 loc) · 1.82 KB
/
bashrc_configuracion.sh
File metadata and controls
executable file
·71 lines (56 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
set -e
echo "Configurando bashrc con prompt personalizado"
# Crear copia de seguridad
if [ -f ~/.bashrc ]; then
cp ~/.bashrc ~/.bashrc_backup
echo "Copia de seguridad creada: ~/.bashrc_backup"
fi
# Agregar configuración al final del .bashrc
cat >> ~/.bashrc << 'EOF'
# ====== BASH PROMPT CON 3 COLORES ======
# Colores: Cyan, Amarillo, Naranja + Blanco para input
COLOR1="\[\e[38;5;51m\]" # Cyan brillante
COLOR2="\[\e[38;5;226m\]" # Amarillo brillante
COLOR3="\[\e[38;5;214m\]" # Naranja brillante
WHITE="\[\e[38;5;255m\]" # Blanco para lo que escribo
# Python venv info
venv_info() {
if [[ -n "$VIRTUAL_ENV" ]]; then
echo "$(basename "$VIRTUAL_ENV") "
fi
}
# Git info CON detalles completos
parse_git_branch() {
local branch=$(git symbolic-ref --short HEAD 2>/dev/null)
if [[ -n $branch ]]; then
# Contar archivos modificados
local modified=$(git diff --name-only 2>/dev/null | wc -l)
# Contar archivos untracked
local untracked=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l)
# Contar commits totales
local commits=$(git rev-list --count HEAD 2>/dev/null 2>/dev/null)
local details=""
if [[ $modified -gt 0 ]]; then
details="${details} ${modified} modified"
fi
if [[ $untracked -gt 0 ]]; then
details="${details} ${untracked} untracked"
fi
if [[ $commits -gt 0 ]]; then
details="${details} ${commits} commits"
fi
echo "[${branch}${details}]"
fi
}
# Disable Python's default venv prefix
export VIRTUAL_ENV_DISABLE_PROMPT=1
# PS1 con 3 colores + blanco
PS1_CUSTOM="${COLOR1}\$(venv_info)${COLOR2}\w ${COLOR3}\$(parse_git_branch)\n${WHITE}\$ "
export PS1=$PS1_CUSTOM
EOF
echo "Bashrc configurado"
echo ""
echo "Recarga con: source ~/.bashrc"
echo "Para restaurar: cp ~/.bashrc_backup ~/.bashrc"
echo ""