-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.prompt.sh
150 lines (127 loc) · 4.59 KB
/
.prompt.sh
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env bash
# Copyright (C) 2016-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (C) 2016-present Sven Greb <development@svengreb.de>
# Project: igloo
# Repository: https://github.com/arcticicestudio/igloo
# License: MIT
# References:
# http://stackoverflow.com/questions/19092488/custom-bash-prompt-is-overwriting-itself/19501525#19501528
# http://mywiki.wooledge.org/BashFAQ/053
# +-----------------+
# + Git Integration +
# +-----------------+
# +--- Dirty State ---+
# Show unstaged (*) and staged (+) changes.
# Also configurable per repository via "bash.showDirtyState".
GIT_PS1_SHOWDIRTYSTATE=true
# +--- Stash State ---+
# Show currently stashed ($) changes.
GIT_PS1_SHOWSTASHSTATE=false
# +--- Untracked Files ---+
# Show untracked (%) changes.
# Also configurable per repository via "bash.showUntrackedFiles".
GIT_PS1_SHOWUNTRACKEDFILES=true
# +--- Upstream Difference ---+
# Show indicator for difference between HEAD and its upstream.
#
# < Behind upstream
# > Ahead upstream
# <> Diverged upstream
# = Equal upstream
#
# Control behaviour by setting to a space-separated list of values:
# auto Automatically show indicators
# verbose Show number of commits ahead/behind (+/-) upstream
# name If verbose, then also show the upstream abbrev name
# legacy Do not use the '--count' option available in recent versions of git-rev-list
# git Always compare HEAD to @{upstream}
# svn Always compare HEAD to your SVN upstream
#
# By default, __git_ps1 will compare HEAD to SVN upstream ('@{upstream}' if not available).
# Also configurable per repository via "bash.showUpstream".
GIT_PS1_SHOWUPSTREAM="auto verbose name"
# +--- Describe Style ---+
# Show more information about the identity of commits checked out as a detached HEAD.
#
# Control behaviour by setting to one of these values:
# contains Relative to newer annotated tag (v1.6.3.2~35)
# branch Relative to newer tag or branch (master~4)
# describe Relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
# default Exactly matching tag
GIT_PS1_DESCRIBE_STYLE="contains"
# +--- Colored Hints ---+
# Show colored hints about the current dirty state. The colors are based on the colored output of "git status -sb".
# NOTE: Only available when using __git_ps1 for PROMPT_COMMAND!
GIT_PS1_SHOWCOLORHINTS=true
# +--- pwd Ignore ---+
# Disable __git_ps1 output when the current directory is set up to be ignored by git.
# Also configurable per repository via "bash.hideIfPwdIgnored".
GIT_PS1_HIDE_IF_PWD_IGNORED=false
compile_prompt () {
local EXIT=$?
local CONNECTBAR_DOWN=$'\u250C\u2500\u257C'
local CONNECTBAR_UP=$'\u2514\u2500\u257C'
local GITSPLITBAR=$'\u2570\u257C'
local SPLITBAR=$'\u257E\u2500\u257C'
local ARROW=$'\u25B6'
local c_gray='\e[01;30m'
local c_blue='\e[0;34m'
local c_cyan='\e[0;36m'
local c_reset='\e[0m'
# > Connectbar Down
# Format:
# (newline)(bright colors)(connectbar down)
PS1="\n${c_gray}"
PS1+="$CONNECTBAR_DOWN"
# > Username
# Format:
# (bracket open)(username)(bracket close)(splitbar)
PS1+="[${c_blue}\u${c_cyan}@${c_blue}\h${c_gray}]"
PS1+="$SPLITBAR"
# > Jobs
# Format:
# (bracket open)(jobs)(bracket close)(splitbar)
PS1+="[${c_blue}\j${c_gray}]"
# > Exit Status
# Format:
# (bracket open)(last exit status)(bracket close)(splitbar)
PS1+="[${c_blue}${EXIT}${c_gray}]"
PS1+="$SPLITBAR"
# > Time
# Format:
# (bracket open)(time)(bracket close)(newline)(connectbar up)
PS1+="[${c_blue}\D{%H:%M:%S}${c_gray}]\n"
PS1+="$CONNECTBAR_UP"
# > Working Directory
# Format:
# (bracket open)(working directory)(bracket close)(newline)
PS1+="[${c_blue}\w${c_gray}]"
if [ $(command -v pyenv) ]; then
PS1+="$SPLITBAR"
PS1+="[${c_blue}python: $(pyenv version-name)${c_gray}]"
fi
if [ $(command -v kubectl) ]; then
PS1+="$SPLITBAR"
PS1+="[${c_blue}k8s: $(kubectl config current-context)${c_gray}]"
fi
# if [ "x$(__venv_ps1)" != "x" ]; then
# PS1+="$SPLITBAR"
# PS1+="[${c_blue}$(__venv_ps1)${c_gray}]"
# fi
PS1+="\n"
# > Git
# Format:
# (gitsplitbar)(bracket open)(git branch)(bracket close)(splitbar)
# (bracket open)(HEAD-SHA)(bracket close)
PS1+="$(__git_ps1 " \\u2570\\u257C[${c_cyan}%s${c_gray}]\\u257E\\u2500\\u257C[${c_cyan}$(git rev-parse --short HEAD 2> /dev/null)${c_gray}]")"
# Append additional newline if in git repository
if [[ ! -z $(__git_ps1) ]]; then
PS1+='\n'
fi
# > Arrow
# NOTE: Color must be escaped with '\[\]' to fix the text overflow bug!
# Format:
# (arrow)(color reset)
PS1+="$ARROW \[\e[0m\]"
}
PROMPT_COMMAND='compile_prompt'