|
1 | | -# thx to https://github.com/mduvall/config/ |
2 | 1 |
|
3 | 2 | function subl --description 'Open Sublime Text' |
4 | 3 | if test -d "/Applications/Sublime Text.app" |
|
87 | 86 |
|
88 | 87 | function all_binaries_in_path --description \ |
89 | 88 | "list all binaries available in \$PATH (incl conflicts). pipe it to grep. top-most are what's used, in case of conflicts" |
90 | | - # based on https://unix.stackexchange.com/a/120790/110766 but tweaked to work on mac. and then made it faster. |
91 | | - find -L $PATH -maxdepth 1 -executable -type f 2>/dev/null |
| 89 | + # based on https://unix.stackexchange.com/a/120790/110766. and then made it faster. needs `brew install findutils` |
| 90 | + gfind -L $PATH -maxdepth 1 -executable -type f 2>/dev/null |
| 91 | +end |
92 | 92 |
|
93 | | - # list path |
94 | | - # for val in $PATH; echo "$val"; end |
| 93 | +function all_binaries_in_path_grep --description "run all_binaries_in_path and grep with your argument" |
| 94 | + all_binaries_in_path | grep $argv |
95 | 95 | end |
96 | 96 |
|
97 | | -function list_path --description "list all paths in PATH" |
| 97 | +function list_path --description "list all paths in PATH, top-most wins" |
98 | 98 | for val in $PATH; echo "$val"; end |
99 | 99 | end |
100 | 100 |
|
101 | | -function my_paths --description "list paths, in order" |
102 | | - echo "# " |
103 | | - printf '%s\n' (string split \n $PATH) |
104 | | -end |
| 101 | + |
105 | 102 |
|
106 | 103 | function stab --description "stabalize a video" |
107 | 104 | set -l vid $argv[1] |
@@ -199,25 +196,34 @@ function server -d 'Start a HTTP server in the current dir, optionally specifyin |
199 | 196 | end |
200 | 197 | end |
201 | 198 |
|
| 199 | +# straight from the docs |
| 200 | +function last_history_item |
| 201 | + echo $history[1] |
| 202 | +end |
| 203 | +abbr -a !! --position anywhere --function last_history_item |
| 204 | + |
202 | 205 |
|
203 | | -function conda -d 'lazy initialize conda' |
204 | | - functions --erase conda |
205 | | - eval /opt/miniconda3/bin/conda "shell.fish" "hook" | source |
206 | | - # There's some opportunity to use `psub` but I don't really understand it. |
207 | | - conda $argv |
| 206 | +# I crafted this lazy init pattern. It's lovely. |
| 207 | +# I first did it with functions but it's better with abbr to get completions etc immediately. |
| 208 | +function __lazy_init_conda -d 'lazy initialize conda' |
| 209 | + abbr --erase conda; functions --erase __lazy_init_conda |
| 210 | + eval $(which conda) "shell.fish" "hook" | source |
| 211 | + echo "conda" |
208 | 212 | end |
| 213 | +abbr --add conda --function __lazy_init_conda |
| 214 | + |
| 215 | + |
| 216 | +function __lazy_init_cargo -d 'lazy initialize cargo' |
| 217 | + abbr --erase cargo; functions --erase __lazy_init_cargo |
| 218 | + sh "$HOME/.cargo/env" |
| 219 | + echo "cargo" |
| 220 | +end |
| 221 | +abbr --add cargo --function __lazy_init_cargo |
209 | 222 |
|
210 | 223 | # NVM doesnt support fish and its stupid to try to make it work there. |
| 224 | +# gcloud: Don't need "$HOME/google-cloud-sdk/path.fish.inc" lazyily done because it only adds to PATH which is already done. |
211 | 225 |
|
212 | 226 |
|
213 | | -function google_cloud_sdk_lazy_init -d 'Lazy initializer for Google Cloud SDK' |
214 | | - functions --erase gcloud gsutil bq |
215 | | - source "$HOME/google-cloud-sdk/path.fish.inc" |
216 | | - $argv |
217 | | -end |
218 | | -for cmd in gcloud gsutil bq |
219 | | - eval "function $cmd; google_cloud_sdk_lazy_init $cmd \$argv; end" |
220 | | -end |
221 | 227 |
|
222 | 228 |
|
223 | 229 | function fns --description "Interactively search/preview fish shell functions and aliases" |
|
0 commit comments