-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc
124 lines (110 loc) · 3.91 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
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
main() {
add_to_path "$HOME/.local/bin"
add_to_path "/usr/local/sbin"
add_to_path /home/linuxbrew/.linuxbrew/bin
add_to_path /home/linuxbrew/.linuxbrew/sbin
add_to_path "$HOME/.cargo/bin"
setup_all_the_bash_stuff
command_exists brew && eval "$(brew shellenv)" && [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
command_exists chezmoi && eval "$(chezmoi completion bash)"
command_exists direnv && eval "$(direnv hook bash)"
command_exists terraform && complete -C "$(which terraform)" terraform
if [ -d "$HOME/.asdf" ]; then
source "$HOME/.asdf/asdf.sh"
source "$HOME/.asdf/completions/asdf.bash"
fi
}
create_aliases() {
alias duchs="du -chs .[!.]* * | sort -rn"
alias grep="grep --color=auto --exclude=*~"
if command_exists reattach-to-user-namespace; then
alias ls="ls -G"
command_exists gfind && alias find="gfind"
command_exists gxargs && alias xargs="gxargs"
else
alias ls="ls --color=auto"
fi
command_exists thefuck && eval "$(thefuck --alias shimatta)"
alias pnvim="prj && nvim \"+CtrlP\""
command_exists rg && alias rg="rg --hidden -g '!.git'"
command_exists paplay && alias ding="paplay /usr/share/sounds/freedesktop/stereo/complete.oga"
}
vpn_work() {
local temp_file=$(mktemp)
# TODO: check if BW_SESSION is unset
# BW_SESSION=$(bw unlock --raw)
sudo ls > /dev/null
printf "%s\n%s%s" "$(bw get username "work VPN")" "$(bw get password "work VPN")" "$(bw get totp "work VPN")" > "$temp_file"
sudo openvpn --config /etc/openvpn/ovpn-1-rhvpn-tcp.conf --auth-user-pass "$temp_file" &
sleep 5
rm "$temp_file"
fg
}
setup_environment_variables() {
export EDITOR=nvim
unset MAILCHECK # Never check mail
command_exists mesg && mesg n # Ignore system messages (having every tmux terminal be spammed is annoying)
export NO_AT_BRIDGE=1 # http://unix.stackexchange.com/questions/230238
export HISTSIZE=100000 # More command history! YAY!
export HISTFILESIZE=10000000 # and the space to store those commands
export HISTCONTROL=ignoreboth # Ignore duplicate commands and commands that start with ' '
export HISTCONTROL+=":erasedups" # Erase duplicates form history
export HISTIGNORE="ls:bg:fg:history"
if GPG_TTY=$(tty); then
export GPG_TTY # Enables interactive password entry for gpg
else
echo "WARN: failed to intitialize GPG_TTY"
fi
if SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket); then
export SSH_AUTH_SOCK
else
echo "WARN: failed to intitialize SSH_AUTH_SOCK"
fi
export CHROME_BIN=chromium # Enables angular to find chrome exe
export GCC_COLORS="error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01"
export DOT_GITHUB_HOME="$XDG_CONFIG_HOME"
export PYTHON_CONFIGURE_OPTS="--enable-shared" # Fix asdf python
export BASH_SILENCE_DEPRECATION_WARNING=1 # Silence Mac OS zsh default shell message
local keybase_dir
if command_exists keybase && keybase_dir=$(false && keybase config get --bare mountdir); then
export KEYBASE_DIR=$keybase_dir
fi
}
setup_all_the_bash_stuff() {
set +h # Disable hashing path of executables
set -o vi # Turn on vi-style editing for the command line
command_exists dircolors && eval "$(dircolors)" # Export LS_COLORS fanciness
setup_environment_variables
create_aliases
command_exists starship && enable_starship
}
function always_append_history(){
history -a
}
enable_starship() {
eval "$(starship init bash)"
starship_precmd_user_func="always_append_history"
}
cdf() {
local selection
local FD
if command_exists fdfind; then
FD=fdfind
else
FD=fd
fi
if selection=$($FD --type directory --print0 | fzf --read0); then
cd "$selection"
fi
}
prj() {
local repos_path="$HOME/repos"
local selection
if selection=$(find "$repos_path" -maxdepth 7 -name '.git' -type d -printf '%P\0' 2>/dev/null | sed 's#/.git##g' | fzf --read0); then
cd "$repos_path/$selection" || return
fi
}
main
# vi: ft=bash