-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrcColorCode
More file actions
41 lines (34 loc) · 1.55 KB
/
bashrcColorCode
File metadata and controls
41 lines (34 loc) · 1.55 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
############################################### BASH COLOR UPDATE SCRIPT ###############################################
# Define color variables (with proper Bash prompt escaping)
GREEN="\[\033[01;92m\]" # Bright green
BLUE="\[\033[01;94m\]" # Bright blue
RED="\[\033[01;91m\]" # Bright red
RESET="\[\033[00m\]" # Reset
# Unescaped ANSI codes for inside functions
PLAIN_GREEN="\033[01;92m"
PLAIN_BLUE="\033[01;94m"
PLAIN_RED="\033[01;91m"
PLAIN_RESET="\033[00m"
# Function to parse the current Git branch and changes
parse_git_status() {
if git rev-parse --is-inside-work-tree &>/dev/null; then
local branch="${PLAIN_RED}($(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null))${PLAIN_RESET}"
local changes=""
if [[ -n $(git diff --ignore-submodules) ]] || \
[[ -n $(git diff --cached --ignore-submodules) ]] || \
[[ -n $(git ls-files --others --exclude-standard) ]]; then
changes="${PLAIN_GREEN}*${PLAIN_RESET}"
fi
echo -e " ${branch}${changes}"
fi
}
# Set the PS1 prompt
PS1="${debian_chroot:+($debian_chroot)}${GREEN}\u${RED}@${GREEN}\h${RESET}:${BLUE}\w\[\$(parse_git_status)\]${RESET}\$ "
# Enable color output for ls and friends
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Optional: use default LS_COLORS or customized one
eval "$(dircolors -b)"
############################################# END BASH COLOR UPDATE SCRIPT #############################################