-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bashrc
174 lines (143 loc) · 6.82 KB
/
dot_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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env bash
HISTFILESIZE=100000
HISTSIZE=10000
shopt -s histappend
shopt -s checkwinsize
shopt -s extglob
shopt -s globstar
shopt -s checkjobs
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
# alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
export PROMPT_COMMAND="history -a"
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=5000
HISTFILESIZE=10000
# Expand history commands
bind Space:magic-space
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# Set Terraform plan lock to default false.
export TF_CLI_ARGS_plan="-lock=false"
# Add some well-known directories to $PATH.
export PATH="$HOME/.krew/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
# Add Aqua variables
export AQUA_ROOT_DIR="${XDG_DATA_HOME:-$HOME/.local/share/aquaproj-aqua}"
export PATH="${AQUA_ROOT_DIR}/bin:$PATH"
export AQUA_GLOBAL_CONFIG=${AQUA_GLOBAL_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/aquaproj-aqua/aqua.yaml}
export AQUA_GENERATE_WITH_DETAIL=true
# Activate Mise: https://github.com/jdx/mise.
if command -v mise &> /dev/null; then
eval "$(mise activate bash)"
eval "$(mise hook-env -s bash)"
# Mise itself doesn't export this as a variable as Aqua does do, so we do it ourself
MISE_GLOBAL_CONFIG="$(mise config ls --no-header | head -n1 | awk '{print $1}')"
MISE_GLOBAL_CONFIG="${MISE_GLOBAL_CONFIG//\~/$HOME}"
export MISE_GLOBAL_CONFIG
fi
[[ $- =~ i ]] || return 0 # check if interative session
################################################################
# Only commands that are needed for user should be after here. #
################################################################
# load custom Bash functions and aliases
source ~/.bash_functions
source ~/.bash_aliases
# Update completions by writing them in the completions directory, see https://serverfault.com/a/1013395.
# Note that for now we are immediately calling the function afterwards, but we could decide to not do this if this has performance impact.
function update_completions() {
_completion_dir="$HOME/.local/share/bash-completion/completions"
[ ! -d "${_completion_dir}" ] && { echo "Bash Completion directory does not exists, not updating completions" && return; }
if command -v aqua &> /dev/null; then aqua completion bash > "${_completion_dir}/aqua.bash"; fi
if command -v lab &> /dev/null; then lab completion bash > "${_completion_dir}/lab.bash"; fi
if command -v glab &> /dev/null; then glab completion -s bash > "${_completion_dir}/glab.bash"; fi
if command -v mise &> /dev/null; then mise completion bash > "${_completion_dir}/mise.bash"; fi
if command -v rbw &> /dev/null; then rbw gen-completions bash > "${_completion_dir}/rbw.bash"; fi
if command -v ghorg &> /dev/null; then ghorg completion bash > "${_completion_dir}/ghorg.bash"; fi
if command -v starship &> /dev/null; then starship completions bash > "${_completion_dir}/starship.bash"; fi
if command -v tenv &> /dev/null; then tenv completion bash > "${_completion_dir}/tenv.bash"; fi
if command -v fzf &> /dev/null; then eval "$(fzf --bash)" > "${_completion_dir}/fzf.bash"; fi
}
update_completions
if command -v git-town &> /dev/null; then eval "$(git-town completions bash)"; fi
complete -o default -F __start_git-town gt
alias gt='git-town'
if command -v kubectl &> /dev/null; then
eval "$(kubectl completion bash)"
complete -F __start_kubectl k
alias kubectl='kubecolor'
alias k='kubectl'
# Set `dyff` as the kubectl differ (k diff ...)
export KUBECTL_EXTERNAL_DIFF="dyff between --omit-header --set-exit-code"
fi
# Aqua installed
if command -v lazygit &> /dev/null; then
alias lzg='lazygit'
fi
# Aqua installed
if command -v lazydocker &> /dev/null; then
alias lzd='lazydocker'
fi
# Use another style of providing completions so excluded from the completions function.
if command -v terraform &> /dev/null; then complete -C "$(which terraform)" terraform; fi
if command -v aws_completer &> /dev/null; then complete -C "$(which aws_completer)" aws; fi
# Can be used as fallback when rbw is broken.
if [ -f ~/.env ]; then
set -a
source ~/.env
set +a
fi
##############################################
# BITWARDEN: auto load tokens if DB unlocked #
##############################################
if command -v rbw &> /dev/null; then
if rbw unlocked &> /dev/null; then
echo "🔓🗝️ Session unlocked, loading tokens from Bitwarden... 🔓🗝️"
OPENAI_API_KEY="$(rbw get OPENAI_API_KEY)"
export OPENAI_API_KEY && echo "✍🏾 OPENAI_API_KEY"
gitlab_token="$(rbw get GITLAB_TOKEN)"
export TF_HTTP_PASSWORD="$gitlab_token" && echo "✍🏾 TF_HTTP_PASSWORD" # Authentication for GitLab-Managed Terraform State
export TF_VAR_gitlab_token="$gitlab_token" && echo "✍🏾 TF_VAR_gitlab_token" # Conventional input we use for GitLab Terraform Provider authentication
export GITLAB_TOKEN="$gitlab_token" && echo "✍🏾 GITLAB_TOKEN"
export GL_TOKEN="$gitlab_token" && echo "✍🏾 GL_TOKEN"
export LAB_CORE_TOKEN="$gitlab_token" && echo "✍🏾 LAB_CORE_TOKEN"
github_token="$(rbw get GITHUB_TOKEN)"
export GITHUB_TOKEN="$github_token" && echo "✍🏾 GITHUB_TOKEN"
else
echo "🔒 Bitwarden vault locked, not loading tokens. 🔒"
echo "💡 To load tokens run the \`reco\` alias. 💡"
fi
fi
[ -f "$HOME/.local/share/blesh/ble.sh" ] && source $HOME/.local/share/blesh/ble.sh
function set_win_title() {
echo -ne "\033]0; "$PWD" \007"
}
starship_precmd_user_func="set_win_title"
if command -v thefuck &> /dev/null; then eval "$(thefuck --alias fuck)"; fi # disabled until https://github.com/nvbn/thefuck/pull/1404 is fixed. Unlikely as the issue is over a month old.
if command -v zoxide &> /dev/null; then eval "$(zoxide init --cmd cd bash)"; fi
if command -v starship &> /dev/null; then eval "$(starship init bash --print-full-init)"; fi
if command -v atuin &> /dev/null; then eval "$(atuin init bash)"; fi
if command -v savvy &> /dev/null; then eval "$(savvy init bash)"; fi