-
Notifications
You must be signed in to change notification settings - Fork 3
/
bashrc
176 lines (156 loc) · 4 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
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
175
176
# ~/.bashrc: Options for interactive shells.
shopt -s histappend autocd cdspell checkhash checkjobs globstar
# TODO
#direxpand off
#dirspell off
#dotglob off
#execfail off
#expand_aliases on
#extdebug off
#extglob on
#extquote on
#failglob off
#force_fignore on
#globasciiranges off
#gnu_errfmt off
#histappend on
#histreedit off
#histverify off
#hostcomplete off
#huponexit off
#inherit_errexit off
#interactive_comments on
#lastpipe off
#lithist off
#login_shell off
#mailwarn off
#no_empty_cmd_completion off
#nocaseglob off
#nocasematch off
#nullglob off
#progcomp on
#promptvars on
#restricted_shell off
#shift_verbose off
#sourcepath on
#xpg_echo off
export LESS=-iRFX
# How about no
unset LESSOPEN LESSKEYIN_SYSTEM
export PAGER=less
export MP_FULLNAME="Bryan Thomas Richter"
export MPW_FULLNAME="Bryan Thomas Richter"
export HISTCONTROL=ignoreboth
export HISTSIZE=-1
export HISTTIMEFORMAT="│%F %k:%M:%S│ "
for i in "$HOME/bin" "$HOME/.local/bin"; do
if [ -d "$i" ] ; then
PATH="$i:$PATH"
fi
done
#export PS0='\e[2;31m[\#/\! @ \t]\e[0m\n'
export FIGNORE="*.o:*.hi"
stty -ixon
# Source aux settings in ~/.bash
for i in "$HOME"/.bash/*.bash; do
# shellcheck disable=SC1090 # Can't make this work anyway
. "$i"
done
# Running dircolors with defaults is, for some reason, different than not
# running dircolors.
# shellcheck disable=SC1090 # Can't make this work
. <(dircolors)
## ALIASES + FUNCTIONS
alias cal='cal -3mw'
alias cp='cp --reflink=auto'
alias f=fg
alias g=git
alias j=jobs
alias jb=jobs
alias la='ls -a'
alias n.='ls -ad .*'
alias n=ls
alias nb=nix-build
alias ns=nix-shell
alias pd=pushd
alias rg='rg --colors path:fg:cyan --colors path:style:bold'
alias txr=transmission-remote
alias up='g st'
alias xo=xdg-open
alias xp='xclip -selection clipboard'
alias sc=systemctl
alias usc='systemctl --user'
alias tree='tree -I dist-newstyle'
alias autorandr='autorandr --match-edid'
#
# Fetch keys from keepass, via pass.
#
# "But why?" Because keepass works on Android and it supports TOTP, so it's a
# better source of truth. But pass has a better UI for me on Linux.
# Helper: Unlock keypass with pass
__pass_keepass_unlock () {
declare acct="$1"
shift
pass show "$acct" | keepassxc-cli "$@"
}
# Helper: workhorse wrapper function
__pass_keepass () {
local account action
for arg in account action; do
eval declare "$arg"="$1"
shift
done
case "$account" in
relex)
declare pass_key='keepass-relex'
declare kdbx_path=~/Syncthing/RelexFiles/relex-keepass.kdbx
;;
personal)
declare pass_key='keepass-chreekat'
declare kdbx_path=~/Syncthing/PhoneFiles/chreekat.kdbx
;;
*)
>&2 echo "Unknown account: $account"
return 1
;;
esac
case "$action" in
search|clip)
__pass_keepass_unlock "$pass_key" "$action" "$kdbx_path" "$1"
;;
totp)
__pass_keepass_unlock "$pass_key" show -t "$kdbx_path" "$1" \
| tail -n 1 | xclip -selection clipboard
;;
*)
>&2 echo "Unknown action: $action"
return 1
;;
esac
}
rpl () { __pass_keepass relex search "$1"; }
rpc () { __pass_keepass relex clip "$1"; }
rtotp () { __pass_keepass relex totp "$1"; }
# Unlock keypass for personal
ppl () { __pass_keepass personal search "$1"; }
ppc () { __pass_keepass personal clip "$1"; }
ptotp () { __pass_keepass personal totp "$1"; }
# Pretty ripgrep, with less
prg () { rg -p "$@" | less; }
# ripgrep to vim
qrg () { vim -q <(rg --vimgrep "$@"); }
# git grep to vim
qgg () { vim -q <(git grep --recurse-submodules "$@"); }
mkcd () {
set -e
mkdir -p "$1" && cd "$1"
}
nixos () {
set -e
cd ~/Projects/dotfiles/nixos/
}
# The struggle is real
:q () {
logout
}
eval "$(direnv hook bash)"