|
1 |
+ |
# ~/.zshrc — managed by Guix Home (see home.scm) |
|
2 |
+ |
# |
|
3 |
+ |
# Ported from linux-dotfiles/zsh/dot-zshrc. Plugins and most CLI tools come |
|
4 |
+ |
# from the Guix Home profile rather than /usr/share or Homebrew. |
|
5 |
+ |
|
|
6 |
+ |
# Interactive-only guard |
|
7 |
+ |
case $- in |
|
8 |
+ |
*i*) ;; |
|
9 |
+ |
*) return ;; |
|
10 |
+ |
esac |
|
11 |
+ |
|
|
12 |
+ |
# ============================================================================= |
|
13 |
+ |
# History |
|
14 |
+ |
# ============================================================================= |
|
15 |
+ |
HISTFILE="$HOME/.zsh_history" |
|
16 |
+ |
HISTSIZE=10000 |
|
17 |
+ |
SAVEHIST=10000 |
|
18 |
+ |
setopt EXTENDED_HISTORY |
|
19 |
+ |
setopt HIST_IGNORE_ALL_DUPS # ~ HISTCONTROL=ignoredups |
|
20 |
+ |
setopt HIST_IGNORE_SPACE # ~ HISTCONTROL=ignorespace |
|
21 |
+ |
setopt HIST_REDUCE_BLANKS |
|
22 |
+ |
setopt APPEND_HISTORY # ~ shopt -s histappend |
|
23 |
+ |
setopt INC_APPEND_HISTORY |
|
24 |
+ |
setopt share_history |
|
25 |
+ |
setopt hist_verify |
|
26 |
+ |
|
|
27 |
+ |
|
|
28 |
+ |
# vi mode (matches nushell edit_mode: vi) |
|
29 |
+ |
set -o vi |
|
30 |
+ |
|
|
31 |
+ |
# Edit command in $EDITOR |
|
32 |
+ |
autoload -Uz edit-command-line |
|
33 |
+ |
zle -N edit-command-line |
|
34 |
+ |
bindkey '^O' edit-command-line |
|
35 |
+ |
|
|
36 |
+ |
# ============================================================================= |
|
37 |
+ |
# Environment |
|
38 |
+ |
# ============================================================================= |
|
39 |
+ |
export EDITOR="nvim" |
|
40 |
+ |
export CLICOLOR=1 |
|
41 |
+ |
export TERMINAL="alacritty" |
|
42 |
+ |
|
|
43 |
+ |
# Go |
|
44 |
+ |
export GOPATH="$HOME/.local/share/go" |
|
45 |
+ |
export GOMODCACHE="$HOME/.local/share/go-mod-cache" |
|
46 |
+ |
|
|
47 |
+ |
# bat |
|
48 |
+ |
export BAT_THEME="ansi" |
|
49 |
+ |
export BAT_THEME_DARK="ansi" |
|
50 |
+ |
|
|
51 |
+ |
# gpg |
|
52 |
+ |
export GPG_TTY="$(tty)" |
|
53 |
+ |
|
|
54 |
+ |
# misc |
|
55 |
+ |
export BULLETS_FEEDS="feeds.stevedylan.dev/feed.xml" |
|
56 |
+ |
|
|
57 |
+ |
# pnpm |
|
58 |
+ |
# export PNPM_HOME="$HOME/.local/share/pnpm" |
|
59 |
+ |
|
|
60 |
+ |
# bun |
|
61 |
+ |
# export BUN_INSTALL="$HOME/.bun" |
|
62 |
+ |
|
|
63 |
+ |
# Weather |
|
64 |
+ |
export NWS_LAT="35.0274115" |
|
65 |
+ |
export NWS_LON="-85.3183822" |
|
66 |
+ |
|
|
67 |
+ |
# stops GTK apps relaunching the accessibility bridge |
|
68 |
+ |
export NO_AT_BRIDGE=1 |
|
69 |
+ |
|
|
70 |
+ |
# fzf |
|
71 |
+ |
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude ".git"' |
|
72 |
+ |
export FZF_DEFAULT_OPTS=' |
|
73 |
+ |
--color=fg:8:bold,fg+:15,bg:-1,bg+:-1 |
|
74 |
+ |
--color=hl:10:bold,hl+:10:bold |
|
75 |
+ |
--color=info:8,spinner:9,header:4 |
|
76 |
+ |
--color=prompt:2,pointer:9,marker:1 |
|
77 |
+ |
--color=border:7,label:15:bold,query:15 |
|
78 |
+ |
--border="rounded" |
|
79 |
+ |
--border-label="" |
|
80 |
+ |
--preview-window="border-rounded" |
|
81 |
+ |
--prompt="> " |
|
82 |
+ |
--marker=" " |
|
83 |
+ |
--pointer="◆" |
|
84 |
+ |
--separator="" |
|
85 |
+ |
--scrollbar="" |
|
86 |
+ |
--gutter=" " |
|
87 |
+ |
--info=inline-right' |
|
88 |
+ |
|
|
89 |
+ |
# ============================================================================= |
|
90 |
+ |
# PATH |
|
91 |
+ |
# ============================================================================= |
|
92 |
+ |
# Guix manages the system/profile entries; these are for tools installed |
|
93 |
+ |
# outside of Guix (cargo, bun, foundry, ...). |
|
94 |
+ |
# path_add <dir>: prepend if not already present and dir exists |
|
95 |
+ |
path_add() { |
|
96 |
+ |
case ":$PATH:" in |
|
97 |
+ |
*":$1:"*) ;; |
|
98 |
+ |
*) [ -d "$1" ] && PATH="$1:$PATH" ;; |
|
99 |
+ |
esac |
|
100 |
+ |
} |
|
101 |
+ |
|
|
102 |
+ |
# path_add "$HOME/.cargo/bin" |
|
103 |
+ |
path_add "$HOME/.local/share/go/bin" |
|
104 |
+ |
# path_add "$BUN_INSTALL/bin" |
|
105 |
+ |
# path_add "$HOME/.tmux/plugins/t-smart-tmux-session-manager/bin" |
|
106 |
+ |
# path_add "$HOME/.deno/bin" |
|
107 |
+ |
# path_add "$HOME/.foundry/bin" |
|
108 |
+ |
path_add "$HOME/.local/share" |
|
109 |
+ |
# path_add "$HOME/.local/share/solana/install/active_release/bin" |
|
110 |
+ |
# path_add "$HOME/.aztec/bin" |
|
111 |
+ |
# path_add "$HOME/.nargo/bin" |
|
112 |
+ |
# path_add "$HOME/.helios/bin" |
|
113 |
+ |
# path_add "$HOME/.radicle/bin" |
|
114 |
+ |
# path_add "$HOME/.local/share/fnm" |
|
115 |
+ |
# path_add "$PNPM_HOME" |
|
116 |
+ |
path_add "$HOME/.local/bin" |
|
117 |
+ |
|
|
118 |
+ |
export PATH |
|
119 |
+ |
|
|
120 |
+ |
# fnm (node version manager, not packaged in Guix) |
|
121 |
+ |
# if command -v fnm >/dev/null 2>&1; then |
|
122 |
+ |
# eval "$(fnm env --shell zsh)" |
|
123 |
+ |
# path_add "$FNM_MULTISHELL_PATH/bin" |
|
124 |
+ |
# export PATH |
|
125 |
+ |
# # auto-switch node version on cd when .node-version / .nvmrc present |
|
126 |
+ |
# __fnm_autouse() { |
|
127 |
+ |
# if [ -f .node-version ] || [ -f .nvmrc ]; then |
|
128 |
+ |
# fnm use --silent-if-unchanged 2>/dev/null |
|
129 |
+ |
# fi |
|
130 |
+ |
# } |
|
131 |
+ |
# autoload -Uz add-zsh-hook |
|
132 |
+ |
# add-zsh-hook precmd __fnm_autouse |
|
133 |
+ |
# fi |
|
134 |
+ |
|
|
135 |
+ |
# cargo |
|
136 |
+ |
# [ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" |
|
137 |
+ |
|
|
138 |
+ |
# ============================================================================= |
|
139 |
+ |
# Aliases |
|
140 |
+ |
# ============================================================================= |
|
141 |
+ |
alias ls='eza --icons=always' |
|
142 |
+ |
alias ll='eza -l --icons=always' |
|
143 |
+ |
alias la='eza -a --icons=always' |
|
144 |
+ |
# alias lg='lazygit' |
|
145 |
+ |
# alias nf='neofetch' |
|
146 |
+ |
alias fl='fastfetch -c ~/.config/fastfetch/presets/examples/8.jsonc' |
|
147 |
+ |
alias ff='fastfetch -c ~/.config/fastfetch/presets/examples/20.jsonc' |
|
148 |
+ |
alias nvimrc='nvim ~/.config/nvim' |
|
149 |
+ |
alias shitter='ssh itter' |
|
150 |
+ |
# alias ai='aichat' |
|
151 |
+ |
# alias system='macchina' |
|
152 |
+ |
# alias bonsai='cbonsai -li -t 0.4' |
|
153 |
+ |
# alias lst='lstr --icons --color=always --size' |
|
154 |
+ |
# alias keys='keysmasher' |
|
155 |
+ |
# alias timestamp='node -e "process.stdout.write(new Date().toISOString())"' |
|
156 |
+ |
alias e='emacsclient -nw' |
|
157 |
+ |
|
|
158 |
+ |
# ------------------------------------------- |
|
159 |
+ |
# Suffix Aliases - Open Files by Extension |
|
160 |
+ |
# ------------------------------------------- |
|
161 |
+ |
# Just type the filename to open it with the associated program |
|
162 |
+ |
alias -s json=jless |
|
163 |
+ |
alias -s md=bat |
|
164 |
+ |
alias -s go='$EDITOR' |
|
165 |
+ |
alias -s rs='$EDITOR' |
|
166 |
+ |
alias -s txt=bat |
|
167 |
+ |
alias -s log=bat |
|
168 |
+ |
alias -s py='$EDITOR' |
|
169 |
+ |
alias -s js='$EDITOR' |
|
170 |
+ |
alias -s ts='$EDITOR' |
|
171 |
+ |
alias -s html=xdg-open |
|
172 |
+ |
|
|
173 |
+ |
# ============================================================================= |
|
174 |
+ |
# Functions |
|
175 |
+ |
# ============================================================================= |
|
176 |
+ |
# Open a sesh session via gum filter |
|
177 |
+ |
# t() { |
|
178 |
+ |
# local selected |
|
179 |
+ |
# selected=$(sesh list -i | gum filter --limit 1 --placeholder "Choose a session" --height 50 --prompt="> " --indicator.foreground="2" --match.foreground="2") |
|
180 |
+ |
# if [ -z "$selected" ]; then |
|
181 |
+ |
# echo "No session selected" |
|
182 |
+ |
# else |
|
183 |
+ |
# sesh connect "$selected" |
|
184 |
+ |
# fi |
|
185 |
+ |
# } |
|
186 |
+ |
|
|
187 |
+ |
# Fuzzy-find a file and open in nvim |
|
188 |
+ |
nvimf() { |
|
189 |
+ |
local file |
|
190 |
+ |
file=$(fd --type f --hidden --exclude .git | fzf --preview "bat --color=always {}") |
|
191 |
+ |
if [ -z "$file" ]; then |
|
192 |
+ |
echo "No file selected" |
|
193 |
+ |
else |
|
194 |
+ |
nvim "$file" |
|
195 |
+ |
fi |
|
196 |
+ |
} |
|
197 |
+ |
|
|
198 |
+ |
# Install a tree-sitter parser into the nvim luarocks tree |
|
199 |
+ |
# tsi() { |
|
200 |
+ |
# local parser="$1" |
|
201 |
+ |
# local tree="$HOME/.local/share/nvim/site" |
|
202 |
+ |
# luarocks --lua-version=5.1 "--tree=$tree" install "tree-sitter-$parser" |
|
203 |
+ |
# } |
|
204 |
+ |
|
|
205 |
+ |
# nvim startup time -> grep summary line |
|
206 |
+ |
ns() { |
|
207 |
+ |
rm -f ~/.nvim-startup.txt |
|
208 |
+ |
nvim --headless --startuptime ~/.nvim-startup.txt +qa |
|
209 |
+ |
grep "NVIM STARTED" ~/.nvim-startup.txt |
|
210 |
+ |
} |
|
211 |
+ |
|
|
212 |
+ |
# nvim startup time -> full bat dump |
|
213 |
+ |
nh() { |
|
214 |
+ |
rm -f ~/.nvim-startup.txt |
|
215 |
+ |
nvim --headless --startuptime ~/.nvim-startup.txt +qa |
|
216 |
+ |
bat ~/.nvim-startup.txt |
|
217 |
+ |
} |
|
218 |
+ |
|
|
219 |
+ |
# Copy file contents to clipboard |
|
220 |
+ |
cpf() { |
|
221 |
+ |
xclip -selection clipboard < "$1" |
|
222 |
+ |
echo "✔︎ Copied to clipboard!" |
|
223 |
+ |
} |
|
224 |
+ |
|
|
225 |
+ |
# Set orbiter key to personal |
|
226 |
+ |
# orbiter-personal() { |
|
227 |
+ |
# gum spin --spinner dot --spinner.foreground="2" --title "Updating..." -- orbiter auth --key "$(op read 'op://Personal/orbiter-api-key/credential')" |
|
228 |
+ |
# local check |
|
229 |
+ |
# check=$(gum style --foreground="2" "✓ ") |
|
230 |
+ |
# gum join "$check" "Orbiter key set to personal!" |
|
231 |
+ |
# } |
|
232 |
+ |
|
|
233 |
+ |
# Set orbiter key to orbiter account |
|
234 |
+ |
# orbiter-account() { |
|
235 |
+ |
# gum spin --spinner dot --spinner.foreground="2" --title "Updating..." -- orbiter auth --key "$(op read 'op://Personal/orbiter-account-api-key/credential')" |
|
236 |
+ |
# local check |
|
237 |
+ |
# check=$(gum style --foreground="2" "✓ ") |
|
238 |
+ |
# gum join "$check" "Orbiter key set to Orbiter account!" |
|
239 |
+ |
# } |
|
240 |
+ |
|
|
241 |
+ |
# UTC timestamp for blog frontmatter |
|
242 |
+ |
blogdate() { |
|
243 |
+ |
date -u +"%Y-%m-%dT%H:%M:%SZ" |
|
244 |
+ |
} |
|
245 |
+ |
|
|
246 |
+ |
# ============================================================================= |
|
247 |
+ |
# Completion |
|
248 |
+ |
# ============================================================================= |
|
249 |
+ |
# Pick up completions shipped by packages in the Guix profiles |
|
250 |
+ |
for dir in "$HOME/.guix-home/profile/share/zsh/site-functions" \ |
|
251 |
+ |
"$HOME/.guix-profile/share/zsh/site-functions"; do |
|
252 |
+ |
[ -d "$dir" ] && fpath=("$dir" $fpath) |
|
253 |
+ |
done |
|
254 |
+ |
unset dir |
|
255 |
+ |
|
|
256 |
+ |
# bun completions |
|
257 |
+ |
# [ -s "$BUN_INSTALL/_bun" ] && fpath=("$BUN_INSTALL" $fpath) |
|
258 |
+ |
|
|
259 |
+ |
autoload -Uz compinit |
|
260 |
+ |
compinit |
|
261 |
+ |
|
|
262 |
+ |
# ============================================================================= |
|
263 |
+ |
# Tooling init |
|
264 |
+ |
# ============================================================================= |
|
265 |
+ |
command -v zoxide >/dev/null 2>&1 && eval "$(zoxide init zsh)" |
|
266 |
+ |
command -v starship >/dev/null 2>&1 && eval "$(starship init zsh)" |
|
267 |
+ |
command -v fzf >/dev/null 2>&1 && eval "$(fzf --zsh)" |
|
268 |
+ |
|
|
269 |
+ |
# zsh-autosuggestions and syntax highlighting (from the Guix Home profile). |
|
270 |
+ |
# syntax-highlighting must be sourced last. |
|
271 |
+ |
ZSH_PLUGINS="$HOME/.guix-home/profile/share/zsh/plugins" |
|
272 |
+ |
[ -f "$ZSH_PLUGINS/zsh-autosuggestions/zsh-autosuggestions.zsh" ] && |
|
273 |
+ |
source "$ZSH_PLUGINS/zsh-autosuggestions/zsh-autosuggestions.zsh" |
|
274 |
+ |
[ -f "$ZSH_PLUGINS/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ] && |
|
275 |
+ |
source "$ZSH_PLUGINS/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" |
|
276 |
+ |
unset ZSH_PLUGINS |