-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
74 lines (53 loc) · 2.16 KB
/
bashrc
File metadata and controls
74 lines (53 loc) · 2.16 KB
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
DOTFILES_PATH="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Exports
source "$DOTFILES_PATH/bash_exports"
# Homebrew
if [[ -r /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)" # Intel CPU
elif [[ -r /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)" # Apple Silicon CPU
fi
# bash_completion fallback for macOS
# See: https://itnext.io/programmable-completion-for-bash-on-macos-f81a0103080b
if ! command -v _get_comp_words_by_ref &> /dev/null && [[ -r "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" ]]; then
source "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
fi
# Composer
if command -v composer &> /dev/null; then
source "$DOTFILES_PATH/composer_completion/composer-autocomplete"
export PATH="$PATH:"$(composer global config bin-dir --absolute 2> /dev/null)
fi
# Kubernetes
if command -v kubectl &> /dev/null; then
source "$DOTFILES_PATH/kubectl_completion"
alias k='kubectl'
complete -F __start_kubectl k
function k8s_prompt_update() {
K8S_PROMPT="$(kubectl config current-context 2>/dev/null)"
}
PROMPT_COMMAND="k8s_prompt_update;$PROMPT_COMMAND"
if command -v kubecolor &> /dev/null; then
alias kubectl="kubecolor"
fi
fi
# Aliases
source "$DOTFILES_PATH/bash_aliases"
# Git
if command -v git &> /dev/null; then
source "$DOTFILES_PATH/git_aliases"
source "$DOTFILES_PATH/gitstatus/gitstatus.plugin.sh"
source "$DOTFILES_PATH/git_prompt"
fi
# Prompt
PROMPT_DIRTRIM=3 # Shorten current directory
shopt -s promptvars # Enable promptvars so that ${XXX_PROMPT} in PS1 is expanded
PS1='\[\033[01;32m\]\u@\h\[\033[00m\] ' # green user@host
PS1+='\[\033[01;34m\]\w\[\033[00m\]' # blue current working directory
PS1+='${GITSTATUS_PROMPT:+ [$GITSTATUS_PROMPT]}' # git status (requires promptvars option)
PS1+='${K8S_PROMPT:+ ☸️ $K8S_PROMPT}' # k8s status (requires promptvars option)
PS1+='\n\[\033[01;$((31+!$?))m\]\$\[\033[00m\] ' # green/red (success/error) $/# (normal/root)
PS1+='\[\e]0;\u@\h: \w\a\]' # terminal title: user@host: dir
# Extra
if [[ -r "$DOTFILES_PATH/bash_extra" ]]; then
source "$DOTFILES_PATH/bash_extra"
fi