-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_bashrc
83 lines (70 loc) · 3.21 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
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ History
# ┗━━━━━━━━━━━━━━━━━━━━━━━
export HISTFILE=~/.bash_history
export HISTFILESIZE=
export HISTSIZE=
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ fzf & rg
# ┗━━━━━━━━━━━━━━━━━━━━━━━
export FZF_DEFAULT_OPTS='-m --height 70% --border=sharp --layout=reverse'
if type rg &>/dev/null; then
export FZF_DEFAULT_COMMAND='rg --files --hidden'
fi
test -r /usr/share/fzf/key-bindings.bash && source /usr/share/fzf/key-bindings.bash >/dev/null 2>/dev/null || true
test -r /usr/share/fzf/completion.bash && source /usr/share/fzf/completion.bash >/dev/null 2>/dev/null || true
fzf-workspace-widget() {
local cmd dir
cmd="${FZF_ALT_O_COMMAND:-"command ls -1 $WORKSPACE"}"
dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_O_OPTS" $(__fzfcmd) +m) && printf 'cd -- %q' "$WORKSPACE/$dir"
}
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
bind -m emacs-standard '"\eo": " \C-b\C-k \C-u`fzf-workspace-widget`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'
bind -m vi-command '"\eo": "\C-z\eo\C-z"'
bind -m vi-insert '"\eo": "\C-z\eo\C-z"'
fi
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ starship & zoxide
# ┗━━━━━━━━━━━━━━━━━━━━━━━
command -v starship &>/dev/null && eval "$(starship init bash)"
command -v zoxide &>/dev/null && eval "$(zoxide init bash)"
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ GPG
# ┗━━━━━━━━━━━━━━━━━━━━━━━
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ Utils
# ┗━━━━━━━━━━━━━━━━━━━━━━━
with_ghc() {
local np
np=$(ghcup --offline whereis -d ghc $1 || { ghcup --cache install ghc $1 && ghcup whereis -d ghc $1; })
if [ -e "${np}" ]; then
shift
PATH="$np:$PATH" "$@"
else
echo >&2 "Cannot find or install GHC version $1"
return 1
fi
}
alert() {
local ex="$?"
notify-send "$(history | tail -n 1 | sed -e 's/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//')" "Done! Exit code: ${ex}"
}
library-menu() {
fd -e pdf -e djvu '' Library/\[{Tech,Math}\]* | $MENU --dmenu | xargs -d '\n' -I % $READER "%"
}
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ Aliases
# ┗━━━━━━━━━━━━━━━━━━━━━━━
if command -v exa &>/dev/null; then
alias ls=exa
fi
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ OCaml / OPAM
# ┗━━━━━━━━━━━━━━━━━━━━━━━
test -r ~/.local/share/opam/opam-init/init.sh && source ~/.local/share/opam/opam-init/init.sh >/dev/null 2>/dev/null || true
# ┏━━━━━━━━━━━━━━━━━━━━━━━
# ┃ Lua / LuaRocks
# ┗━━━━━━━━━━━━━━━━━━━━━━━
command -v luarocks &>/dev/null && eval "$(luarocks path --bin)"