-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
35 lines (32 loc) · 1.1 KB
/
.bash_prompt
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
# Configuration for Bash prompt
# Prevent venv from changing the prompt
export VIRTUAL_ENV_DISABLE_PROMPT=1
# Define functions
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
parse_python_env() {
if [[ -n "$VIRTUAL_ENV" ]]; then
echo "($(basename $VIRTUAL_ENV))"
elif [[ -n "$CONDA_DEFAULT_ENV" ]]; then
echo "($(basename $CONDA_DEFAULT_ENV))"
fi
}
# Define color aliases using tput
LIGHT_BLUE="\[$(tput setaf 45)\]"
WHITE="\[$(tput setaf 195)\]"
DARK_BLUE="\[$(tput setaf 39)\]"
ORANGE="\[$(tput setaf 214)\]"
RESET="\[$(tput sgr0)\]"
# Constructing PS1
export PS1="" # Start with an empty prompt
PS1+="${LIGHT_BLUE}\$(parse_python_env) " # Python env information
PS1+="${WHITE}[" # Start bracket
PS1+="${DARK_BLUE}\u" # Username
PS1+="${WHITE}@" # @ symbol
PS1+="${DARK_BLUE}\h " # Hostname
PS1+="${ORANGE}\W" # Working directory base name
PS1+="${LIGHT_BLUE} \$(parse_git_branch)" # Git branch info
PS1+="${WHITE}]" # End bracket
PS1+="${WHITE}\$" # $ or # symbol (based on effective UID)
PS1+="${RESET} " # Reset color to default