-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.fish
381 lines (289 loc) · 11.8 KB
/
config.fish
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#######################################################################
# CJAPPL fish_config
#######################################################################
# .OO
# .OOOO
# .OOOO'
# OOOO' .-~~~~-.
# OOO' / (o)(o)
# .OOOOOO `O .OOOOOOO. / .. |
# .OOOOOOOOOOOO OOOOOOOOOO/\ \____/
# .OOOOOOOOOOOOOOOOOOOOOOOO/ \\ ,\_/
# .OOOOOOO%%OOOOOOOOOOOOO(#/\ /.
# .OOOOOO%%%OOOOOOOOOOOOOOO\ \\ \/OO.
# .OOOOO%%%%OOOOOOOOOOOOOOOOO\ \/OOOO.
# OOOOO%%%%OOOOOOOOOOOOOOOOOOO\_\/\OOOOO
# OOOOO%%%OOOOOOOOOOOOOOOOOOOOO\###)OOOO
# OOOOOO%%OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
# OOOOOOO%OOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
# `OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO'
# .-~~\OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO'
# / _/ `\(#\OOOOOOOOOOOOOOOOOOOOOOOOOOOO'
# / / \ / `~~\OOOOOOOOOOOOOOOOOOOOOOOOOO'
#|/' `\// \\ \OOOOOOOOOOOOOOOOOOOOOOOO'
# `-.__\_,\OOOOOOOOOOOOOOOOOOOOO'
# `OO\#)OOOOOOOOOOOOOOOOOOO'
# `OOOOOOOOO''OOOOOOOOO'
# `""""""' `""""""'
#
#######################################################################
set BREW /opt/homebrew/bin/brew
eval ($BREW shellenv)
if test -d (brew --prefix)"/share/fish/completions"
set -p fish_complete_path (brew --prefix)/share/fish/completions
end
if test -d (brew --prefix)"/share/fish/vendor_completions.d"
set -p fish_complete_path (brew --prefix)/share/fish/vendor_completions.d
end
#######################################################################
# => Environment variables
#######################################################################
# remote logins (ssh)
# PATHS (cd)
set PERSONAL ~/code/personal/
set DOTFILES ~/dotfiles/
set SPATIAL ~/code/spatial
set SPATIAL_API ~/code/spatial-openapi
set ENV staging
set -x RIPGREP_CONFIG_PATH (echo $HOME'/.ripgreprc')
set -x EDITOR (which nvim)
set -x HOMEBREW_NO_ANALYTICS 1
set TOOLROOT_PI /Volumes/xtool-build-env/crosstools_workspace/armv8-rpi3-linux-gnueabihf/
set -x CMAKE_CXX_COMPILER_LAUNCHER ccache
#set -x CCACHE_BASEDIR $SPATIAL
set -x CCACHE_MAXSIZE 10G
set -x OBSIDIAN "$HOME/Obsidian/main_vault"
#######################################################################
# => Aliases and functions
#######################################################################
alias lg "lazygit"
alias rclang "/Users/topher/code/radsan_cjappl/build/bin/clang"
alias rclang++ "/Users/topher/code/radsan_cjappl/build/bin/clang++"
function rgcmake --wraps "rg"
rg --type cmake $argv
end
function rgcpp --wraps "rg"
rg --type cpp $argv
end
function rgpy --wraps "rg"
rg --type py $argv
end
function fdi --wraps "fd"
fd --no-ignore $argv
end
function rgi --wraps "rg"
rg --no-ignore $argv
end
function getparentbranchname
set current_branch_name (git rev-parse --abbrev-ref HEAD)
set parent_branch_name (git show-branch -a 2>/dev/null \
| grep '\*' \
| grep -v $current_branch_name \
| head -n1 \
| grep -o '\[[^]]*\]' \
| head -1 \
| tr -d '[]')
echo $parent_branch_name
end
# Open the Pull Request URL for your current directory's branch, merges by default against the current branch's parent
function openpr
set github_url (git remote -v | grep 'origin.*fetch' | awk '{print $2}' | sed -Ee 's#(git@|git://)#https://#' -e 's@com:@com/@' -e 's%\.git$%%' | awk '/github/')
set current_branch_name (git rev-parse --abbrev-ref HEAD)
# https://gist.github.com/joechrysler/6073741
set parent_branch_name (getparentbranchname)
# https://github.com/spatiallabs/spatial/compare/release-8.4...merge-PLAT-1234?expand=1
set pr_url $github_url"/compare/$parent_branch_name...$current_branch_name?expand=1"
open $pr_url
end
# Run git push and then immediately open the Pull Request URL
function gpr
git push origin HEAD
if test $status -eq 0
openpr
else
echo 'failed to push commits and open a pull request.';
end
end
alias gsc "git switch --create"
# finding my ip address
alias ip_addr "ifconfig en0 inet | grep inet"
#setting vim to start nvim
alias vim nvim
# clear au cache
alias clear_au_cache "rm ~/Library/Caches/AudioUnitCache/com.apple.audiounits.cache && rm ~/Library/Preferences/com.apple.audio.InfoHelper.plist"
alias ls lsd
alias tabonly "tmux kill-window -a && tmux movew -r"
[ -f $HOMEBREW_PREFIX/share/autojump/autojump.fish ]; and source $HOMEBREW_PREFIX/share/autojump/autojump.fish
#######################################################################
# => Utility functions
#######################################################################
set -x CLANG_FORMAT_DIFF /opt/homebrew/Cellar/clang-format/14.0.0/share/clang/clang-format-diff.py
function fish_user_key_bindings
for mode in insert default visual
# Enable ctrl + f for auto complete
# Fish issue 3541
bind -M $mode \cf forward-char
end
fzf_key_bindings
end
# sudo run last command
function please
if count $argv > /dev/null
if [ $history[$argv[1]] = "please" ]
please (math $argv[1] + 1)
else
eval command sudo $history[$argv[1]]
end
else
please 1
end
end
# copy the !! functionality of other shells
function last_history_item; echo $history[1]; end
abbr -a !! --position anywhere --function last_history_item
#######################################################################
# => Fzf
#######################################################################
set -x FORGIT_FZF_DEFAULT_OPTS "$FORGIT_FZF_DEFAULT_OPTS --layout=reverse-list"
source $HOME/code/forgit/conf.d/forgit.plugin.fish
#[ -f $HOMEBREW_PREFIX/share/forgit/forgit.plugin.fish ]; and source $HOMEBREW_PREFIX/share/forgit/forgit.plugin.fish
set -x FZF_DEFAULT_COMMAND "fd --color=always --exclude .git --type file . \$dir"
set -x FZF_CTRL_T_COMMAND $FZF_DEFAULT_COMMAND
set -x FZF_CTRL_T_OPTS '--preview="bat --color=always --number {} 2> /dev/null" --height=80% --preview-window=right:60%:wrap'
set -x FZF_DEFAULT_OPTS "--ansi"
#######################################################################
# => Rust
#######################################################################
[ -d $HOME/.cargo/bin ]; and fish_add_path $HOME/.cargo/bin
#######################################################################
# => colors
#######################################################################
set -x fish_color_user d7ff87
set -x fish_color_cwd ff6b2d
#set -x fish_color_host 2f99d4
set -x fish_color_host 2f99d4
set -x fish_color_operator $fish_color_user
# More prompt configuration
function fish_mode_prompt
switch $fish_bind_mode
case default
set_color --bold $fish_color_cwd
echo '[N]'
case insert
set_color --bold $fish_color_host
echo '[I]'
case replace_one
set_color --bold green
echo '[R]'
case visual
set_color --bold brmagenta
echo '[V]'
case '*'
set_color --bold red
echo '[?]'
end
set_color white
echo ' '
set_color normal
end
#set __fish_git_prompt_show_informative_status true
set __fish_git_prompt_showdirtystate true
set __fish_git_prompt_showuntrackedfiles true
set -x VIRTUAL_ENV_DISABLE_PROMPT true
function fish_prompt -d "Write out the prompt"
if set -q VIRTUAL_ENV
echo -n -s (set_color white) "(" (basename "$VIRTUAL_ENV") ")" (set_color normal) " "
end
# This shows up as /home/user/ (master *)>, with the directory colored
printf '%s%s' (set_color $fish_color_cwd) (prompt_pwd)
set_color normal
fish_git_prompt
set_color aacf9f
printf '> '
set_color normal
end
set -g fish_user_paths "/usr/local/opt/ruby/bin" $fish_user_paths
set fish_greeting ""
fish_vi_key_bindings
######## # Colors for less manpage
set default (tput sgr0)
set red (tput setaf 1)
set green (tput setaf 2)
set purple (tput setaf 5)
set orange (tput setaf 9)
# Less colors for man pages
set -x PAGER less
# Begin blinking
set -x LESS_TERMCAP_mb $red
# Begin bold
set -x LESS_TERMCAP_md $orange
# End mode
set -x LESS_TERMCAP_me $default
# End standout-mode
set -x LESS_TERMCAP_se $default
# Begin standout-mode - info box
set -x LESS_TERMCAP_so $purple
# End underline
set -x LESS_TERMCAP_ue $default
# Begin underline
set -x LESS_TERMCAP_us $green
# set folders to be teal for fish ls
set -Ux LSCOLORS gxfxbEaEBxxEhEhBaDaCaD
thefuck --alias | source
# Use forgit diff on stash enter
set -x FORGIT_STASH_ENTER_COMMAND 'echo {} | cut -d: -f1 | xargs -I % git forgit diff %^1 %'
# Pop stash on alt-enter
set -x FORGIT_STASH_POP_COMMAND 'echo {} | cut -d: -f1 | xargs -I % git stash pop %'
# Drop stash on alt-backspace
set -x FORGIT_STASH_DROP_COMMAND 'echo {} | cut -d: -f1 | xargs -I % git stash drop %'
set -x FORGIT_STASH_FZF_OPTS "
--bind='enter:execute($FORGIT_STASH_ENTER_COMMAND)'
--bind='ctrl-a:execute($FORGIT_STASH_POP_COMMAND)+accept'
--bind='ctrl-x:execute($FORGIT_STASH_DROP_COMMAND)+reload(git stash list)'
--prompt='[ENTER] show [CTRL+a] pop [CTRL+x] drop > '"
set -x RTSAN_LOCAL_BUILD_DIR "$HOME/code/radsan_cjappl/llvm-project/build/"
set -x RTSAN_CLANG_BIN "$RTSAN_LOCAL_BUILD_DIR/bin/clang"
set -x RTSAN_CLANGXX_BIN "$RTSAN_LOCAL_BUILD_DIR/bin/clang++"
set RTSAN_LIT_OPTS_ENV "LIT_OPTS=\"--filter=.*rtsan.*|attributes.ll|fsanitize.c|compatibility.ll --allow-empty-runs\""
function ,mrremote --description 'Remote rtsan build'
set_common_targets
set BUILD_DIR "/Users/topher/code/radsan/build/"
set LOCAL_LLVM_DIR "/Users/topher/code/radsan_cjappl/llvm-project/"
rsync -avz --delete --force --exclude "build*" --exclude ".cache" $LOCAL_LLVM_DIR/ topher@Kates-MBP-2:$HOME/code/radsan/llvm-project/; or return $status;
caffeinate -di ssh topher@Kates-MBP-2 "export PATH=\"/opt/homebrew/bin:\$PATH\" && cmake --build $BUILD_DIR --target $RTSAN_TARGETS_CLANG"; or return $status;
caffeinate -di ssh topher@Kates-MBP-2 "export PATH=\"/opt/homebrew/bin:\$PATH\" && export $RTSAN_LIT_OPTS_ENV && cmake --build $BUILD_DIR --target $RTSAN_TARGETS_LIT"; or return $status;
end
function set_common_targets
set -g RTSAN_TARGETS_CLANG clang check-rtsan
set -g RTSAN_TARGETS_LIT check-llvm check-clang-codegen check-clang-driver
end
function ,mrlocal --description 'Local rtsan build'
set_common_targets
set BUILD_DIR $RTSAN_LOCAL_BUILD_DIR
set NPROCS (math (sysctl -n hw.ncpu) - 2)
set RTSAN_LIT_OPTS_ENV "LIT_OPTS=--filter=.*rtsan.*|attributes.ll|fsanitize.c|compatibility.ll --allow-empty-runs"
caffeinate -di cmake --build $BUILD_DIR --target $RTSAN_TARGETS_CLANG -j $NPROCS; or return $status;
caffeinate -di env $RTSAN_LIT_OPTS_ENV cmake --build $BUILD_DIR --target $RTSAN_TARGETS_LIT -j $NPROCS; or return $status;
end
function ,mrdocker --description 'Ubuntu docker rtsan build'
set_common_targets
set IMAGE_NAME radsan-segfault
set BUILD_DIR "/test_radsan/build_debug_ubuntu"
set ENV_VARS "CCACHE_DIR=/test_radsan/ccache_ubuntu"
set VOLUME_MOUNT "$HOME/code/radsan_cjappl:/test_radsan"
caffeinate -di docker run -it -e $ENV_VARS -v $VOLUME_MOUNT $IMAGE_NAME:latest cmake --build $BUILD_DIR --target $RTSAN_TARGETS_CLANG; or return $status;
caffeinate -di docker run -it -e $ENV_VARS -v $VOLUME_MOUNT -e $RTSAN_LIT_OPTS_ENV $IMAGE_NAME:latest cmake --build $BUILD_DIR --target $RTSAN_TARGETS_LIT; or return $status;
end
abbr -a cops "gh copilot suggest \""
abbr -a cope "gh copilot explain \""
set -gx NVM_DIR "$HOME/.nvm"
# 2anki
set ANKI_SERVER_DIR ~/code/2anki/server
set ANKI_WEB_DIR $ANKI_SERVER_DIR/web
export WORKSPACE_BASE=$ANKI_SERVER_DIR/workspace
alias run_anki_server "npm run dev --prefix $ANKI_SERVER_DIR"
alias run_anki_web "npm run dev --prefix $ANKI_WEB_DIR"
function obsi_to_anki
/Users/topher/.virtualenvs/anki_gen/bin/python $HOME/code/Obsidian_to_Anki/obsidian_to_anki.py -R "$OBSIDIAN" --regex
end
git machete completion fish | source