-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
74 lines (61 loc) · 2.71 KB
/
.bashrc
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
# source global definitions
[ -e /etc/bashrc ] &&
. /etc/bashrc
[ -e /etc/bashrc.cloudshell ] &&
. /etc/bashrc.cloudshell
# add go utils to path if go is available
which go >/dev/null 2>&1 &&
echo $PATH | grep -v $(go env GOPATH)/bin >/dev/null &&
PATH=$PATH:$(go env GOPATH)/bin
which minikube >/dev/null 2>&1 &&
. <(minikube completion bash) &&
complete -o default -F __start_minikube minikube.exe
which kubectl >/dev/null 2>&1 &&
. <(kubectl completion bash) &&
alias k=kubectl &&
complete -o default -F __start_kubectl k &&
complete -o default -F __start_kubectl kubectl.exe
which helm >/dev/null 2>&1 &&
. <(helm completion bash)
which kind >/dev/null 2>&1 &&
. <(kind completion bash)
[ -e ~/lib/git-completion.bash ] &&
. ~/lib/git-completion.bash
[ -e ~/lib/oci_autocomplete.sh ] &&
. ~/lib/oci_autocomplete.sh
alias update.bashrc="curl https://raw.githubusercontent.com/vpasechnik/shell-scripts/main/.bashrc -o ~/.bashrc"
alias install.inputrc="curl https://raw.githubusercontent.com/vpasechnik/shell-scripts/main/.inputrc -o ~/.inputrc"
alias install.glab.cli="go install gitlab.com/gitlab-org/cli/cmd/glab@main"
alias install.yq="go install github.com/mikefarah/yq/v4@latest"
alias install.git.completion="mkdir -p ~/lib && curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/lib/git-completion.bash && . ~/lib/git-completion.bash"
function __set_my_prompt
{
local NOCOLOR="\[\033[0m\]"
local RED="\[\033[0;31m\]"
local GREEN="\[\033[0;32m\]"
local YELLOW="\[\033[0;33m\]"
local BLACK="\[\033[0;30m\]"
local ps_git=""
local git_branch="$(git branch --show-current 2>/dev/null)"
if [ "$git_branch" != "" ]; then
local git_modified_color="${GREEN}"
local git_status="$(git status 2>/dev/null | grep "Your branch is ahead" 2>/dev/null)"
if [ "$git_status" != "" ]; then
git_modified_color="${YELLOW}"
fi
local git_status="$(git status --porcelain 2>/dev/null)"
if [ "$git_status" != "" ]; then
git_modified_color="${RED}"
fi
ps_git=" ${NOCOLOR}($git_modified_color$git_branch${NOCOLOR})${NOCOLOR}"
fi
local ps_kubectl=""
if which kubectl > /dev/null 2>&1 ; then
local kubectl_context="$(kubectl config current-context 2>/dev/null)"
local kubectl_ns="$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)"
[ "${kubectl_context}" != "" ] &&
ps_kubectl="\n${NOCOLOR}(k8s|${GREEN}${kubectl_context}${NOCOLOR}:${RED}${kubectl_ns}${NOCOLOR}) "
fi
PS1="${GREEN}\u@\h:${YELLOW}\w${NOCOLOR}${ps_git}${ps_kubectl}\n\$ "
}
PROMPT_COMMAND='__set_my_prompt'