-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_prompt
78 lines (65 loc) · 2.79 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
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
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >& /dev/null; then
export TERM='gnome-256color'
elif infocmp xterm-256color >& /dev/null; then
export TERM='xterm-256color'
fi;
# Regular Colors
black="\[\033[0;30m\]"
red="\[\033[0;31m\]"
green="\[\033[0;32m\]"
yellow="\[\033[0;33m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
cyan="\[\033[0;36m\]"
white="\[\033[0;37m\]"
highBlack="\[\033[0;90m\]"
highRed="\[\033[0;91m\]"
highGreen="\[\033[0;92m\]"
highYellow="\[\033[0;93m\]"
highBlue="\[\033[0;94m\]"
highPurple="\[\033[0;95m\]"
highCyan="\[\033[0;96m\]"
highWhite="\[\033[0;97m\]"
# Highlight the user name when logged in as root.
if [[ "${USER}" == "root" ]]; then
userStyle="${red}"
else
userStyle="${yellow}"
fi
function short_pwd () {
# Only show ellipses for directory trees -gt 3
# Otherwise use the default pwd as the current \w replacement
if [ $(pwd | grep -o '/' | wc -l) -gt 3 ]; then
pwd | cut -d'/' -f1-3 | xargs -I{} echo {}"/../${PWD##*/}"
else
pwd
fi
}
export BASH_GIT_PROMPT_HOME="$HOME/.bash-git-prompt" \
&& [ -d "/usr/local/opt/bash-git-prompt/share" ] \
&& export BASH_GIT_PROMPT_HOME="/usr/local/opt/bash-git-prompt/share"
echo "BASH_GIT_PROMPT_HOME=${BASH_GIT_PROMPT_HOME}"
if [ -f "${BASH_GIT_PROMPT_HOME}/gitprompt.sh" ]; then
__GIT_PROMPT_DIR=$BASH_GIT_PROMPT_HOME
# GIT_PROMPT_ONLY_IN_REPO=1 # use git prompt everywhere
# GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status
# GIT_PROMPT_IGNORE_SUBMODULES=1 # uncomment to avoid searching for changed files in submodules
# GIT_PROMPT_WITH_VIRTUAL_ENV=0 # uncomment to avoid setting virtual environment infos for node/python/conda environments
# GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch
# GIT_PROMPT_SHOW_UNTRACKED_FILES=normal # can be no, normal or all; determines counting of untracked files
# GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=0 # uncomment to avoid printing the number of changed files
# GIT_PROMPT_STATUS_COMMAND=gitstatus_pre-1.7.10.sh # uncomment to support Git older than 1.7.10
#GIT_PROMPT_START+="${highCyan}[\D{%s}] " # date/time 24-hour
GIT_PROMPT_START+="${userStyle}\u" # username
GIT_PROMPT_START+="${white}@"
GIT_PROMPT_START+="${purple}\h" # host
GIT_PROMPT_START+="${white}:"
GIT_PROMPT_START+="${green}\$(short_pwd)" # working directory full path
# GIT_PROMPT_END=... # uncomment for custom prompt end sequence
# as last entry source the gitprompt script
GIT_PROMPT_THEME=Single_line_Solarized # use custom theme specified in file GIT_PROMPT_THEME_FILE (default ~/.git-prompt-colors.sh)
# GIT_PROMPT_THEME_FILE=~/.git-prompt-colors.sh
# GIT_PROMPT_THEME=Solarized # use theme optimized for solarized color scheme
source "${BASH_GIT_PROMPT_HOME}/gitprompt.sh"
fi