-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_bashrc.tmpl
More file actions
286 lines (252 loc) · 8.29 KB
/
dot_bashrc.tmpl
File metadata and controls
286 lines (252 loc) · 8.29 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# ~/.bashrc
# =====================
# 0. XDG & ENVIRONMENT
# =====================
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$UID}"
if [ ! -d "$XDG_RUNTIME_DIR" ]; then
export XDG_RUNTIME_DIR="/tmp/$USER-runtime"
mkdir -pm 0700 "$XDG_RUNTIME_DIR"
fi
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export XDG_CACHE_HOME="$HOME/.cache"
mkdir -p "$XDG_CONFIG_HOME" "$XDG_DATA_HOME" "$XDG_STATE_HOME" "$XDG_CACHE_HOME"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
export GOPATH="$XDG_DATA_HOME/go"
export NODE_REPL_HISTORY="$XDG_STATE_HOME/node_repl_history"
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc"
export HISTFILE="$XDG_STATE_HOME/bash/history"
export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc"
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm"
export NPM_CONFIG_TMP="${XDG_RUNTIME_DIR:-$XDG_CACHE_HOME/npm_tmp}"
export RANDFILE="$XDG_STATE_HOME/openssl_rnd"
export PYTHON_HISTORY="$XDG_STATE_HOME/python_history"
export SCREENRC="$XDG_CONFIG_HOME/screen/screenrc"
export XINITRC="$XDG_CONFIG_HOME/X11/xinitrc"
export CODEX_HOME="$XDG_CONFIG_HOME/codex"
# Device-Specific Environment Tweaks
{{- if eq .chezmoi.os "linux" }}
{{- if and (hasKey .chezmoi.kernel "osrelease") (.chezmoi.kernel.osrelease | lower | contains "microsoft") }}
# WSL Specific
export BROWSER=wslview
{{- else if eq .chezmoi.hostname "stormux" }}
# Raspberry Pi Specific: Force manual 1Password mode
export OP_BIOMETRIC_UNLOCK_ENABLED=false
{{- end }}
{{- end }}
export PAGER="less -Ri"
# =====================
# 1. Exported Variables
# =====================
export EXA_API_KEY={{ onepasswordRead "op://Personal/Exa API Key/credential" }}
export GITHUB_PERSONAL_ACCESS_TOKEN={{ onepasswordRead "op://Personal/GitHub MCP Server Token/credential" }}
export GOOGLE_CLIENT_ID={{ onepasswordRead "op://Personal/Google Cloud MCP-Omnibus Keys/username" }}
export GOOGLE_CLIENT_SECRET={{ onepasswordRead "op://Personal/Google Cloud MCP-Omnibus Keys/credential" }}
# =====================
# 2. INTERACTIVE CHECK
# =====================
[[ $- != *i* ]] && return
# =====================
# 3. HISTORY & SHELL BEHAVIOR
# =====================
HISTSIZE=10000
HISTFILESIZE=10000
HISTCONTROL=ignoredups:erasedups
shopt -s histappend
shopt -s autocd
shopt -s checkwinsize
shopt -s cmdhist
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }history -a; history -n"
# =====================
# 4. PATH
# =====================
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) PATH="$HOME/.local/bin:$PATH" ;;
esac
case ":$PATH:" in
*":$HOME/bin:"*) ;;
*) PATH="$HOME/bin:$PATH" ;;
esac
export PATH
# Add npm global binaries to PATH
case ":$PATH:" in
*":$HOME/.local/share/npm-global/bin:"*) ;;
*) PATH="$HOME/.local/share/npm-global/bin:$PATH" ;;
esac
# Add custom Cargo binaries to PATH
case ":$PATH:" in
*":$CARGO_HOME/bin:"*) ;;
*) PATH="$CARGO_HOME/bin:$PATH" ;;
esac
# Add Go binaries to PATH
case ":$PATH:" in
*":$GOPATH/bin:"*) ;;
*) PATH="$GOPATH/bin:$PATH" ;;
esac
# Boot.dev Worldbanc Path
case ":$PATH:" in
*":$HOME/worldbanc/private/bin:"*) ;;
*) PATH="$HOME/worldbanc/private/bin:$PATH" ;;
esac
# =====================
# 5. EDITOR & DIALOGS
# =====================
export EDITOR="code-insiders --wait"
export VISUAL="code-insiders --wait"
{{- if eq .chezmoi.os "linux" }}
{{- if hasKey .chezmoi.kernel "osrelease" }}
{{- if (.chezmoi.kernel.osrelease | lower | contains "microsoft") }}
export SUDO_EDITOR="/mnt/c/Users/Windows11/AppData/Local/Programs/Microsoft VS Code Insiders/bin/code-insiders --wait"
{{- end }}
{{- end }}
{{- end }}
export DIALOGOPTS='--no-lines --visit-items'
export GPG_TTY="$(tty 2>/dev/null)"
# =====================
# 6. COMPLETION & SHELL SETUP
# =====================
# Readline keybindings
bind 'set completion-ignore-case on'
bind 'set show-all-if-ambiguous on'
bind 'set page-completions off'
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\e[1;5C": forward-word'
bind '"\e[1;5D": backward-word'
bind '"\e[5C": forward-word'
bind '"\e[5D": backward-word'
bind '"\e[H": beginning-of-line'
bind '"\e[F": end-of-line'
bind '"\e[1~": beginning-of-line'
bind '"\e[4~": end-of-line'
# Bash completion framework
if [[ -r /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
fi
# bootdev CLI completions
if [[ -r ~/.bootdev_completion ]]; then
. ~/.bootdev_completion
fi
# Tool shell integrations
eval "$(fzf --bash)" 2>/dev/null
eval "$(zoxide init bash)" 2>/dev/null
eval "$(pieces completion bash)" 2>/dev/null
eval "$(starship init bash)" 2>/dev/null
# Tealdeer (tldr) maintenance
if command -v tldr >/dev/null 2>&1; then
(tldr --update >/dev/null 2>&1 &)
fi
# =====================
# 7. ALIASES & EXPORTS
# =====================
# File & Directory
alias ll='eza -l'
alias la='eza -la'
alias lt='eza --tree'
alias lta='eza --tree -a'
alias wget="wget --hsts-file=$XDG_CACHE_HOME/wget-hsts"
alias fp='fzf --preview "bat --style=numbers --color=always --line-range :500 {}"'
alias rg='rg --smart-case'
# Safer file operations
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
# Navigation
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias ex='cd ~/exercism'
# Jump to a project directory using fzf and zoxide
pj() {
local dir
dir=$(zoxide query -l | fzf --height 40% --reverse --header="Jump to directory") && cd "$dir"
}
# Git
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git pull'
alias gd='git diff'
alias gco='git checkout'
alias gb='git branch'
alias gcb='git checkout -b'
# Chezmoi
alias cz='chezmoi'
alias cza='chezmoi apply'
alias cze='chezmoi edit'
alias c='clear'
alias reload='source ~/.bashrc'
{{- if eq .chezmoi.os "linux" }}
{{- if hasKey .chezmoi.kernel "osrelease" }}
{{- if (.chezmoi.kernel.osrelease | lower | contains "microsoft") }}
unalias open 2>/dev/null
if command -v wslview >/dev/null 2>&1; then
alias open='wslview'
fi
alias winpath='wslpath -w'
alias clip='clip.exe'
alias winget='winget.exe'
{{- end }}
{{- end }}
# Linux Package Exporter
export_linux_packages() {
local dir="$HOME/.local/share/chezmoi/package-lists/linux"
mkdir -p "$dir"
echo -e "\e[36mExporting Linux package lists to $dir...\e[0m"
if command -v pacman >/dev/null 2>&1; then pacman -Qqe > "$dir/pacman.txt"; fi
if command -v cargo >/dev/null 2>&1; then cargo install --list > "$dir/cargo.txt"; fi
if command -v uv >/dev/null 2>&1; then uv tool list > "$dir/uv.txt"; fi
if command -v npm >/dev/null 2>&1; then npm list -g --depth=0 > "$dir/npm.txt"; fi
if command -v pip >/dev/null 2>&1; then pip list > "$dir/pip.txt"; fi
echo -e "\e[32mDone! Lists saved to chezmoi source.\e[0m"
}
alias expl='export_linux_packages'
{{- end }}
# Modern Rust-tooling
alias ls='eza --icons --group-directories-first'
alias cat='bat --paging=never'
alias du='dust'
alias ch='choose'
alias tldr='tldr'
# QMK Keymap Shortcuts
alias qk='cd ~/qmk_firmware/keyboards/keychron/k10_max/ansi/rgb/keymaps/lanie/'
alias qkf='cd ~/qmk_firmware && qk && qmk flash -kb keychron/k10_max/ansi/rgb -km lanie'
# Foam Wiki Shortcuts
alias foam="node ~/foam/packages/foam-cli/out/index.js"
export FOAM_WORKSPACE="/home/lanie/lanie-signal"
# =====================
# 8. CUSTOM FUNCTIONS & REMINDERS
# =====================
bible_reader_reminder() {
local bin_file="$HOME/projects/bible-reader/.venv/bin/maybe-read-bible"
local stamp_file="$HOME/.local/state/bible-reader/last_prompt_date.txt"
local today
[[ -f "$bin_file" ]] || return
today="$(date +%F)"
if [[ -f "$stamp_file" ]]; then
local last_stamp=""
if ! IFS= read -r last_stamp <"$stamp_file"; then
last_stamp=""
fi
[[ "$last_stamp" == "$today" ]] && return
fi
printf '\nBible reading pending. Run: br\n\n'
}
alias br='"$HOME/projects/bible-reader/.venv/bin/maybe-read-bible"'
bible_reader_reminder
# Sanitize blog drafts by removing checkboxes and fixing whitespace
sanitize_blog() {
if [ -z "$1" ]; then
echo "Usage: sanitize_blog <filename>"
return 1
fi
echo "Cleaning $1..."
sed -i -e 's/- \[[ x]\] .*//g' "$1"
sed -i -e '/^$/N;/^\n$/D' "$1"
echo "Logic preserved. File cleaned."
}