-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bashrc
141 lines (112 loc) · 3.07 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
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
# shellcheck shell=bash
# shellcheck disable=SC1090
# vi mode
set -o vi
# append history instead of rewriting it
shopt -s histappend
# save multi-line commands in history as single line
shopt -s cmdhist
# autocorrects cd misspellings
shopt -s cdspell
# include dotfiles in pathname expansio
shopt -s dotglob
# expand aliases
shopt -s expand_aliases
# enable extended pattern-matching features
shopt -s extglob
# pathname expansion will be treated as case-insensitive
shopt -s nocaseglob
# brew
if command -v brew &>/dev/null; then
eval "$(brew shellenv)"
fi
# starship
if command -v starship &>/dev/null; then
eval "$(starship init bash)"
fi
# bash completions
if [ -r /etc/bash_completion ]; then
# shellcheck disable=SC1091
source /etc/bash_completion
fi
if [ -r /etc/profile.d/bash_completion.sh ]; then
# shellcheck disable=SC1091
source /etc/profile.d/bash_completion.sh
fi
# https://docs.brew.sh/Shell-Completion
if [ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]; then
export BASH_COMPLETION_COMPAT_DIR="${HOMEBREW_PREFIX}/etc/bash_completion.d"
# shellcheck disable=SC1091
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
else
for completion in "${HOMEBREW_PREFIX}"/etc/bash_completion.d/*; do
[ -r "$completion" ] && source "$completion"
done
fi
# Save bash history after each command, depend `shopt -s histappend`
PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND"
# chruby
if [ -f "${HOMEBREW_PREFIX}/share/chruby/chruby.sh" ]; then
# shellcheck disable=SC2034
RUBIES=("${HOME}/.rubies/*")
# shellcheck source=/dev/null
source "${HOMEBREW_PREFIX}/share/chruby/chruby.sh"
# shellcheck source=/dev/null
source "${HOMEBREW_PREFIX}/share/chruby/auto.sh"
fi
if command -v zoxide &>/dev/null; then
eval "$(zoxide init bash)"
fi
if command -v direnv &>/dev/null; then
eval "$(direnv hook bash)"
fi
# gcloud
GCLOUD_SDK="${HOME}/.google-cloud-sdk"
if [ -f "${GCLOUD_SDK}/path.bash.inc" ] &&
[ -f "${GCLOUD_SDK}/completion.bash.inc" ]; then
# shellcheck source=/dev/null
source "${GCLOUD_SDK}/path.bash.inc"
# shellcheck source=/dev/null
source "${GCLOUD_SDK}/completion.bash.inc"
fi
# fzf
if command -v fzf &>/dev/null; then
eval "$(fzf --bash)"
fi
# nomad
if command -v nomad &>/dev/null; then
complete -C nomad nomad
fi
# Auto attach|start ssh-agent
SSH_AGENT="${HOME}/.ssh-agent"
if [ -r "$SSH_AGENT" ]; then
eval "$(<"$SSH_AGENT")" >/dev/null
fi
if [ -z "$SSH_AGENT_PID" ] || ! kill -0 "$SSH_AGENT_PID" &>/dev/null; then
(
umask 066
ssh-agent >"$SSH_AGENT"
)
eval "$(<"$SSH_AGENT")" >/dev/null
fi
if ! ssh-add -l &>/dev/null; then
trap '' SIGINT
ssh-add -t 8h
trap - SIGINT
fi
# Aliases
if [ -f "${HOME}/.aliases" ]; then
# shellcheck source=/dev/null
source "${HOME}/.aliases"
fi
# ~/.extra can be used for other settings you don't want to commit.
if [ -f "${HOME}/.extra" ]; then
# shellcheck source=/dev/null
source "${HOME}/.extra"
fi
# Auto start|attach zellij session
if command -v zellij &>/dev/null; then
if [ -z "$ZELLIJ" ]; then
zellij attach -c 'BDS 🐑'
fi
fi