-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_prompt
85 lines (79 loc) · 3.09 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
79
80
81
82
83
84
85
#!/usr/bin/env bash
## Modified @gf3's Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
## Modified from from https://github.com/gf3/dotfiles
## http://stackoverflow.com/questions/16715103/bash-prompt-with-last-exit-code
if [[ $COLORTERM == gnome-* && $TERM == xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
if tput setaf 1 &>/dev/null; then
tput sgr0
# if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
# else
#BLACK=$(tput setaf 0)
__RED=$(tput setaf 1)
__GREEN=$(tput setaf 2)
__YELLOW=$(tput setaf 3)
__BLUE=$(tput setaf 4)
__PURPLE=$(tput setaf 5)
__CYAN=$(tput setaf 6)
__WHITE=$(tput setaf 7)
# fi
__BOLD=$(tput bold)
__RESET=$(tput sgr0)
__ROOT=$(tput setab 1)$(tput setaf 7)
else
__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"
__BOLD=""
__RESET="\033[m"
__ROOT="\033[30;41m"
fi
export __RED
export __GREEN
export __YELLOW
export __BLUE
export __PURPLE
export __CYAN
export __WHITE
export __BOLD
export __RESET
export __ROOT
export __USER="\[${__GREEN}\]\u"
export __USER=""
if [ "$(whoami)" = "root" ]; then
export __USER="\[${__ROOT}\]\u"
fi
export __HOST="\[${__BLUE}\]@\[${__CYAN}\]\h"
export __HOST="\[${__CYAN}\]$(kubectl config current-context 2> /dev/null)\[${__WHITE}\]:"
export __DIR="\[${__YELLOW}\]\w\[${__RESET}\]"
export __DATE="\[${__PURPLE}\]\D{%Y-%m-%d %H:%M:%S %Z%z}"
export __DEFAULT1="\[${__PURPLE}\]"
export __DEFAULT2="\[${__YELLOW}\]"
export __SIGN="%"
if [ "$(whoami)" = "root" ]; then
export __SIGN="#"
fi
export __NEWLINE="\[$__RESET\]\n"
# Set config variables first
GIT_PROMPT_ONLY_IN_REPO=0
GIT_PROMPT_FETCH_REMOTE_STATUS=0 # 0 to avoid fetching remote status
GIT_PROMPT_IGNORE_SUBMODULES=1 # 1 to avoid searching for changed files in submodules
#GIT_PROMPT_SHOW_UPSTREAM=1 # 1 to show upstream tracking branch
GIT_PROMPT_SHOW_UNTRACKED_FILES=no # can be no, normal or all; determines counting of untracked files
#GIT_PROMPT_SHOW_CHANGED_FILES_COUNT=0 # 0 to avoid printing the number of changed files
GIT_PROMPT_START="_LAST_COMMAND_INDICATOR_ ${__USER}${__HOST}${__DIR} ${__DATE}\[${__RESET}\]" # for custom prompt start sequence
GIT_PROMPT_END="${__NEWLINE}${__DEFAULT1}${__SIGN} \[${__RESET}\]" # for custom prompt end sequence
## Attempt to use bash-git-prompt https://github.com/magicmonty/bash-git-prompt
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
source "$HOME/.bash-git-prompt/gitprompt.sh"
elif [ -f "/usr/local/opt/bash-git-prompt/share/gitprompt.sh" ]; then
__GIT_PROMPT_DIR="/usr/local/opt/bash-git-prompt/share"
source "/usr/local/opt/bash-git-prompt/share/gitprompt.sh"
fi