···11+complete -xc fin -s h -l help -d "Show usage help"
22+complete -xc fin -s q -l quiet -d "Enable quiet mode"
33+complete -xc fin -s v -l version -d "Show version information"
44+complete -xc fin -n "__fish_use_subcommand" -a install -d "Install plugins / i"
55+complete -xc fin -n "__fish_use_subcommand" -a update -d "Update fin and plugins / u"
66+complete -xc fin -n "__fish_use_subcommand" -a rm -d "Remove plugins / r"
77+complete -xc fin -n "__fish_use_subcommand" -a ls -d "List plugins / l"
88+complete -xc fin -n "__fish_use_subcommand" -a help -d "Show help / h"
+1-9
fish/config.fish
···1111# channel.
1212set -gx NIX_PATH nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs
13131414-set fisher_home $DOTFILES/fish/fisherman
1515-set fisher_config $HOME/.config/fisherman
1616-source $fisher_home/config.fish
1717-1818-theme base16-ocean dark
1919-2020-# set fish_greeting (fortune zen)
1414+# theme base16-ocean dark
21152216enable direnv hook fish
2317enable hub alias -s
2418enable jump shell fish
2519enable rbenv init -
2620enable thefuck --alias
2727-2828-agnoster powerline
···11+# The MIT License (MIT)
22+#
33+# Copyright (c) 2016 Jorge Bucaran
44+#
55+# Permission is hereby granted, free of charge, to any person obtaining a copy of
66+# this software and associated documentation files (the "Software"), to deal in
77+# the Software without restriction, including without limitation the rights to
88+# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
99+# the Software, and to permit persons to whom the Software is furnished to do so,
1010+# subject to the following conditions:
1111+#
1212+# The above copyright notice and this permission notice shall be included in all
1313+# copies or substantial portions of the Software.
1414+#
1515+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1717+# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1818+# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1919+# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2020+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121+2222+2323+set -g fin_version "1.0.0-beta"
2424+2525+2626+function __fin_install
2727+ if test -z "$argv"
2828+ __fin_read_bundle_file | read -az argv
2929+ end
3030+3131+ set -e __fin_fetch_plugins_state
3232+3333+ if set -l fetched (__fin_plugin_fetch_items (__fin_plugin_get_missing $argv))
3434+ if test -z "$fetched"
3535+ set -l count (count $argv)
3636+3737+ if test "$count" -eq 1
3838+ if test -d "$argv[1]"
3939+ set argv[1] (__fin_plugin_normalize_path "$argv[1]")
4040+ end
4141+4242+ set -l base (__fin_plugin_get_names "$argv[1]")[1]
4343+4444+ __fin_log warn "
4545+ It seems @$base@ is already installed
4646+ __""$fin_config/$base""__
4747+ " $__fin_stderr
4848+4949+ else
5050+ __fin_log warn "No plugins to install or missing dependencies." $__fin_stderr
5151+5252+ __fin_log says "
5353+5454+ If you tried to install any plugins, it's likely
5555+ they are already installed in your shell. To see
5656+ what's installed, run @fin ls@.
5757+ " $__fin_stderr
5858+ end
5959+6060+ return 1
6161+ end
6262+6363+ for i in $fetched
6464+ __fin_plugin_enable "$fin_config/$i"
6565+ end
6666+6767+ else
6868+ __fin_log error "
6969+ There was an error cloning @$fetched@.
7070+ " $__fin_stderr
7171+7272+ __fin_log says "
7373+7474+ You can use a url or prepend a namespace to
7575+ the plugin's name, for example: @omf@/$fetched
7676+ " $__fin_stderr
7777+7878+ return 1
7979+ end
8080+end
8181+8282+8383+function __fin_plugin_fetch_items
8484+ __fin_show_spinner
8585+8686+ set -l jobs
8787+ set -l links
8888+ set -l white
8989+ set -l count (count $argv)
9090+9191+ if test "$count" -eq 0
9292+ return
9393+ end
9494+9595+ switch "$__fin_fetch_plugins_state"
9696+ case ""
9797+ if test "$count" = 1
9898+ __fin_log says "Installing @$count@ plugin" $__fin_stderr
9999+ else
100100+ __fin_log says "Installing @$count@ plugins" $__fin_stderr
101101+ end
102102+103103+ set -g __fin_fetch_plugins_state "fetching"
104104+105105+ case "fetching"
106106+ __fin_log says "Installing @$count@ dependencies" $__fin_stderr
107107+ set -g __fin_fetch_plugins_state "done"
108108+109109+ case "done"
110110+ end
111111+112112+ for i in $argv
113113+ set -l names
114114+115115+ switch "$i"
116116+ case \*gist.github.com\*
117117+ __fin_log says "Resolving gist name..."
118118+ if not set names (__fin_get_plugin_name_from_gist "$i") ""
119119+ __fin_log error "
120120+ I couldn't find your gist
121121+ @$i@
122122+ "
123123+ continue
124124+ end
125125+126126+ case \*
127127+ set names (__fin_plugin_get_names "$i")
128128+ end
129129+130130+ if test -d "$i"
131131+ command ln -sfF "$i" "$fin_config/$names[1]"
132132+ set links $links "$names[1]"
133133+ continue
134134+ end
135135+136136+ set -l source "$fin_cache/$names[1]"
137137+138138+ if test -z "$names[2]"
139139+ if test -d "$source"
140140+ if test -L "$source"
141141+ command ln -sfF "$source" "$fin_config"
142142+ else
143143+ command cp -rf "$source" "$fin_config"
144144+ end
145145+ else
146146+ set jobs $jobs (__fin_plugin_url_clone_async "$i" "$names[1]")
147147+ end
148148+ else
149149+ if test -d "$source"
150150+ set -l real_namespace (__fin_plugin_get_url_info --dirname "$source" )
151151+152152+ if test "$real_namespace" = "$names[2]"
153153+ command cp -rf "$source" "$fin_config"
154154+ else
155155+ set jobs $jobs (__fin_plugin_url_clone_async "$i" "$names[1]")
156156+ end
157157+ else
158158+ set jobs $jobs (__fin_plugin_url_clone_async "$i" "$names[1]")
159159+ end
160160+ end
161161+162162+ set fetched $fetched "$names[1]"
163163+ end
164164+165165+ __fin_jobs_await $jobs
166166+167167+ for i in $fetched
168168+ if test ! -d "$fin_cache/$i"
169169+ printf "%s\n" "$i"
170170+ return 1
171171+ end
172172+ end
173173+174174+ if test ! -z "$fetched"
175175+ __fin_plugin_fetch_items (__fin_plugin_get_missing $fetched)
176176+ printf "%s\n" $fetched
177177+ end
178178+179179+ if test ! -z "$links"
180180+ __fin_plugin_fetch_items (__fin_plugin_get_missing $links)
181181+ printf "%s\n" $links
182182+ end
183183+end
184184+185185+186186+function __fin_plugin_url_clone_async -a url name
187187+ switch "$url"
188188+ case https://\*
189189+ case github.com/\*
190190+ set url "https://$url"
191191+192192+ case \?\*/\?\*
193193+ set url "https://github.com/$url"
194194+195195+ case \*
196196+ set url "https://github.com/fishery/$url"
197197+ end
198198+199199+ set -l nc (set_color normal)
200200+ set -l red (set_color red)
201201+ set -l uline (set_color -u)
202202+ set -l green (set_color green)
203203+ set -l magenta (set_color magenta)
204204+205205+ set -l hm_url (printf "%s\n" "$url" | sed 's|^https://||')
206206+207207+ fish -c "
208208+ set -lx GIT_ASKPASS /bin/echo
209209+210210+ if command git clone -q --depth 1 '$url' '$fin_cache/$name' ^ /dev/null
211211+ printf 'fin $green""OKAY""$nc $magenta%18s$nc $uline%s$nc\n' '$name' '$hm_url'
212212+ command cp -rf '$fin_cache/$name' '$fin_config'
213213+ else
214214+ printf 'fin $red""ARGH""$nc $magenta%18s$nc $uline%s$nc\n' '$name' '$hm_url'
215215+ end
216216+ " > /dev/stderr &
217217+218218+ __fin_jobs_get -l
219219+end
220220+221221+222222+function __fin_update
223223+ set -l jobs
224224+ set -l count (count $argv)
225225+ set -l updated
226226+227227+ if test "$count" = 0
228228+ return
229229+ end
230230+231231+ if test "$count" -eq 1
232232+ __fin_log says "Updating @$count@ plugin" $__fin_stderr
233233+ else
234234+ __fin_log says "Updating @$count@ plugins" $__fin_stderr
235235+ end
236236+237237+ for i in $argv
238238+ set -l path "$fin_config/$i"
239239+240240+ if test -d "$path"
241241+ set updated $updated "$i"
242242+ set jobs $jobs (__fin_update_path_async "$i" "$path")
243243+ else
244244+ __fin_log warn "@$i@ is not installed"
245245+ end
246246+ end
247247+248248+ __fin_jobs_await $jobs
249249+250250+ set -g __fin_fetch_plugins_state "fetching"
251251+ set -l fetched (__fin_plugin_fetch_items (__fin_plugin_get_missing $updated))
252252+253253+ for i in $updated $fetched
254254+ if test "$i" = "$fin_active_prompt"
255255+ set fin_active_prompt
256256+ end
257257+ __fin_plugin_enable "$fin_config/$i"
258258+ end
259259+end
260260+261261+262262+function __fin_self_update
263263+ set -l raw_url "https://raw.githubusercontent.com/fishery/fin/master/fin.fish"
264264+ set -l fake_qs (date "+%s")
265265+ set -l file (status --current-filename)
266266+267267+ set -l previous_version "$fin_version"
268268+269269+ fish -c "curl --max-time 5 -sS '$raw_url?$fake_qs' > $file.$fake_qs" &
270270+271271+ __fin_jobs_await (__fin_jobs_get -l)
272272+273273+ if test -s "$file.$fake_qs"
274274+ command mv "$file.$fake_qs" "$file"
275275+ end
276276+277277+ source "$file"
278278+ fin -v > /dev/null
279279+ set -l new_version "$fin_version"
280280+281281+ if test "$previous_version" = "$fin_version"
282282+ __fin_log says "@fin is up to date@" $__fin_stderr
283283+ else
284284+ __fin_log okay "You are now running fin @$fin_version@" $__fin_stderr
285285+286286+ __fin_log says "
287287+288288+ To see the change log, please visit:
289289+ __https://github.com/fishery/fin/releases
290290+ " $__fin_stderr
291291+ end
292292+end
293293+294294+295295+function __fin_update_path_async -a name path
296296+ set -l nc (set_color normal)
297297+ set -l red (set_color red)
298298+ set -l uline (set_color -u)
299299+ set -l green (set_color green)
300300+ set -l magenta (set_color magenta)
301301+302302+ fish -c "
303303+304304+ pushd $path
305305+306306+ if not command git fetch -q origin master ^ /dev/null
307307+ printf 'fin $red""ARGH""$nc $magenta%18s$nc $red✘$nc fetch error\n' '$name'
308308+ exit
309309+ end
310310+311311+ set -l commits (command git rev-list --left-right --count master..FETCH_HEAD ^ /dev/null | cut -d\t -f2)
312312+313313+ command git reset -q --hard FETCH_HEAD ^ /dev/null
314314+ command git clean -qdfx
315315+316316+ if test -z \"\$commits\" -o \"\$commits\" -eq 0
317317+ printf 'fin $green""OKAY""$nc $magenta%18s$nc $green•$nc up to date\n' '$name'
318318+ command cp -rf '$path' '$fin_cache/$name'
319319+ else
320320+ printf 'fin $green""OKAY""$nc $magenta%18s$nc $green▸$nc $magenta%s$nc new commits\n' '$name' \$commits
321321+ end
322322+323323+ " > /dev/stderr &
324324+325325+ __fin_jobs_get -l
326326+end
327327+328328+329329+function __fin_plugin_enable -a path
330330+ if __fin_plugin_is_prompt "$path"
331331+ if test ! -z "$fin_active_prompt"
332332+ __fin_plugin_disable "$fin_config/$fin_active_prompt"
333333+ end
334334+335335+ set -U fin_active_prompt (basename "$path")
336336+ end
337337+338338+ set -l plugin_name (basename $path)
339339+340340+ for file in $path/{functions/*,}*.fish
341341+ set -l base (basename "$file")
342342+343343+ if test "$base" = "uninstall.fish"
344344+ continue
345345+ end
346346+347347+ switch "$base"
348348+ case {,fish_}key_bindings.fish
349349+ __fin_key_bindings_append "$plugin_name" "$file"
350350+ continue
351351+ end
352352+353353+ set -l dir "functions"
354354+355355+ if test "$base" = "init.fish"
356356+ set dir "conf.d"
357357+358358+ set base "$plugin_name.$base"
359359+ end
360360+361361+ set -l target "$fish_config/$dir/$base"
362362+363363+ command ln -sfF "$file" "$target"
364364+ builtin source "$target"
365365+366366+ if test "$base" = "set_color_custom.fish"
367367+ printf "%s\n" "$fish_color_normal" "$fish_color_command" "$fish_color_param" "$fish_color_redirection" "$fish_color_comment" "$fish_color_error" "$fish_color_escape" "$fish_color_operator" "$fish_color_end" "$fish_color_quote" "$fish_color_autosuggestion" "$fish_color_user" "$fish_color_valid_path" "$fish_color_cwd" "$fish_color_cwd_root" "$fish_color_match" "$fish_color_search_match" "$fish_color_selection" "$fish_pager_color_prefix" "$fish_pager_color_completion" "$fish_pager_color_description" "$fish_pager_color_progress" "$fish_color_history_current" "$fish_color_host" > "$fish_config/fish_colors"
368368+ set_color_custom
369369+ end
370370+ end
371371+372372+ for file in $path/conf.d/*.{py,awk}
373373+ set -l base (basename "$file")
374374+ command ln -sfF "$file" "$fish_config/conf.d/$base"
375375+ end
376376+377377+ for file in $path/{functions/,}*.{py,awk}
378378+ set -l base (basename "$file")
379379+ command ln -sfF "$file" "$fish_config/functions/$base"
380380+ end
381381+382382+ for file in $path/conf.d/*.fish
383383+ set -l base (basename "$file")
384384+ set -l target "$fish_config/conf.d/$base"
385385+386386+ command ln -sfF "$file" "$target"
387387+ builtin source "$target"
388388+ end
389389+390390+ for file in $path/completions/*.fish
391391+ set -l base (basename "$file")
392392+ set -l target "$fish_config/completions/$base"
393393+394394+ command ln -sfF "$file" "$target"
395395+ builtin source "$target"
396396+ end
397397+398398+ return 0
399399+end
400400+401401+402402+function __fin_plugin_disable -a path
403403+ set -l plugin_name (basename $path)
404404+405405+ for file in $path/{functions/*,}*.fish
406406+ set -l name (basename "$file" .fish)
407407+ set -l base "$name.fish"
408408+409409+ if test "$base" = "uninstall.fish"
410410+ builtin source "$file"
411411+ continue
412412+ end
413413+414414+ switch "$base"
415415+ case {,fish_}key_bindings.fish
416416+ __fin_key_bindings_remove "$plugin_name"
417417+ continue
418418+ end
419419+420420+ set -l dir "functions"
421421+422422+ if test "$base" = "init.fish"
423423+ set dir "conf.d"
424424+ set base "$plugin_name.$base"
425425+ end
426426+427427+ command rm -f "$fish_config/$dir/$base"
428428+429429+ functions -e "$name"
430430+431431+ if test "$base" = "set_color_custom.fish"
432432+ set -l fish_colors_config "$fish_config/fish_colors"
433433+434434+ if test ! -f "$fish_colors_config"
435435+ __fin_reset_default_fish_colors
436436+ continue
437437+ end
438438+439439+ set -l IFS \n
440440+441441+ read -laz colors < $fish_colors_config
442442+ set colors[25] ""
443443+444444+ set -l IFS " "
445445+446446+ echo "$colors[1]" | read -a -U fish_color_normal
447447+ echo "$colors[2]" | read -a -U fish_color_command
448448+ echo "$colors[3]" | read -a -U fish_color_param
449449+ echo "$colors[4]" | read -a -U fish_color_redirection
450450+ echo "$colors[5]" | read -a -U fish_color_comment
451451+ echo "$colors[6]" | read -a -U fish_color_error
452452+ echo "$colors[7]" | read -a -U fish_color_escape
453453+ echo "$colors[8]" | read -a -U fish_color_operator
454454+ echo "$colors[9]" | read -a -U fish_color_end
455455+ echo "$colors[10]" | read -a -U fish_color_quote
456456+ echo "$colors[11]" | read -a -U fish_color_autosuggestion
457457+ echo "$colors[12]" | read -a -U fish_color_user
458458+ echo "$colors[13]" | read -a -U fish_color_valid_path
459459+ echo "$colors[14]" | read -a -U fish_color_cwd
460460+ echo "$colors[15]" | read -a -U fish_color_cwd_root
461461+ echo "$colors[16]" | read -a -U fish_color_match
462462+ echo "$colors[17]" | read -a -U fish_color_search_match
463463+ echo "$colors[18]" | read -a -U fish_color_selection
464464+ echo "$colors[19]" | read -a -U fish_pager_color_prefix
465465+ echo "$colors[20]" | read -a -U fish_pager_color_completion
466466+ echo "$colors[21]" | read -a -U fish_pager_color_description
467467+ echo "$colors[22]" | read -a -U fish_pager_color_progress
468468+ echo "$colors[23]" | read -a -U fish_color_history_current
469469+ echo "$colors[24]" | read -a -U fish_color_host
470470+471471+ command rm -f $fish_colors_config
472472+ end
473473+ end
474474+475475+ for file in $path/conf.d/*.{py,awk}
476476+ set -l base (basename "$file")
477477+ command rm -f "$fish_config/conf.d/$base"
478478+ end
479479+480480+ for file in $path/{functions/,}*.{py,awk}
481481+ set -l base (basename "$file")
482482+ command rm -f "$fish_config/functions/$base"
483483+ end
484484+485485+ for file in $path/conf.d/*.fish
486486+ set -l base (basename "$file")
487487+ command rm -f "$fish_config/conf.d/$base"
488488+ end
489489+490490+ for file in $path/completions/*.fish
491491+ set -l name (basename "$file" .fish)
492492+ set -l base "$name.fish"
493493+494494+ command rm -f "$fish_config/completions/$base"
495495+ complete -c "$name" --erase
496496+ end
497497+498498+ if __fin_plugin_is_prompt "$path"
499499+ set -U fin_active_prompt
500500+ builtin source $__fish_datadir/functions/fish_prompt.fish ^ /dev/null
501501+ end
502502+503503+ command rm -rf "$path" > /dev/stderr
504504+end
505505+506506+507507+function __fin_get_plugin_name_from_gist -a url
508508+ set -l gist_id (printf "%s\n" "$url" | command sed 's|.*/||')
509509+ set -l name (fish -c "
510510+511511+ fin -v > /dev/null
512512+ curl -Ss https://api.github.com/gists/$gist_id &
513513+514514+ __fin_jobs_await (__fin_jobs_get -l)
515515+516516+ " | command awk '
517517+518518+ /"files": / {
519519+ files++
520520+ }
521521+522522+ /"[^ ]+.fish": / && files {
523523+ gsub("^ *\"|\.fish.*", "")
524524+ print
525525+ }
526526+527527+ ')
528528+529529+ if test -z "$name"
530530+ return 1
531531+ end
532532+533533+ printf "%s\n" $name
534534+end
535535+536536+537537+function __fin_list
538538+ set -l config $fin_config/*
539539+540540+ if test -z "$config"
541541+ return 1
542542+ end
543543+544544+ set -l white
545545+ set -l links (command find $config -maxdepth 0 -type l ! -name "$fin_active_prompt" ^ /dev/null)
546546+ set -l names (command find $config -maxdepth 0 -type d ! -name "$fin_active_prompt" ^ /dev/null)
547547+548548+ if test ! -z "$links"
549549+ set white " "
550550+ printf "%s\n" $links | command sed "s|.*/|@ |"
551551+ end
552552+553553+ if test ! -z "$fin_active_prompt"
554554+ set white " "
555555+ printf "* %s\n" "$fin_active_prompt"
556556+ end
557557+558558+ if test ! -z "$names"
559559+ printf "%s\n" $names | command sed "s|.*/|$white|"
560560+ end
561561+end
562562+563563+564564+function __fin_list_plugin_directory -a item
565565+ set -l fd $__fin_stderr
566566+567567+ set -e argv[1]
568568+ set -l path "$fin_config/$item"
569569+570570+ if test ! -d "$path"
571571+ __fin_log error "$item is not installed" $__fin_stderr
572572+573573+ return 1
574574+ end
575575+576576+ pushd "$path"
577577+578578+ set -l color (set_color $fish_color_command)
579579+ set -l nc (set_color normal)
580580+ set -l inside_tree
581581+582582+ if contains -- --no-color $argv
583583+ set color
584584+ set nc
585585+ set fd $__fin_stdout
586586+ end
587587+588588+ printf "$color%s$nc\n" "$PWD" > $fd
589589+590590+ for file in .* **
591591+ if test -f "$file"
592592+ switch "$file"
593593+ case .\*
594594+ printf " %s\n" $file
595595+ set inside_tree
596596+597597+ case \*/\*
598598+ if test -z "$inside_tree"
599599+ printf " $color%s/$nc\n" (dirname $file)
600600+ set inside_tree -
601601+ end
602602+ printf " %s\n" (basename $file)
603603+604604+ case \*
605605+ printf " %s\n" $file
606606+ set inside_tree
607607+ end
608608+ end
609609+ end > $fd
610610+611611+ popd
612612+end
613613+614614+615615+function __fin_log -a log message fd
616616+ set -l nc (set_color normal)
617617+ set -l red (set_color red)
618618+ set -l warn (set_color black -b yellow)
619619+ set -l green (set_color green)
620620+ set -l bold (set_color magenta)
621621+ set -l uline (set_color -u)
622622+623623+ switch "$fd"
624624+ case "/dev/null"
625625+ return
626626+627627+ case "" "/dev/stderr"
628628+ set fd "/dev/stderr"
629629+630630+ case \*
631631+ set nc ""
632632+ set red ""
633633+ set warn ""
634634+ set green ""
635635+ set bold ""
636636+ set uline
637637+ end
638638+639639+ printf "%s\n" "$message" | command awk '
640640+ function okay(name, s) {
641641+ printf("'$nc'%s '$green'%s'$nc' %s\n", name, "OKAY", s)
642642+ }
643643+644644+ function says(name, s) {
645645+ printf("'$nc'%s '$green'%s'$nc' %s\n", name, "SAYS", s)
646646+ }
647647+648648+ function warn(name, s) {
649649+ printf("'$nc'%s '$warn'%s'$nc' %s\n", name, "WARN", s)
650650+ }
651651+652652+ function error(name, s) {
653653+ printf("'$nc'%s '$red'%s'$nc' %s\n", name, "ARGH", s)
654654+ }
655655+656656+ {
657657+ sub(/^[ ]+/, "")
658658+ gsub("``", " ")
659659+660660+ if (/@[^@]+@/) {
661661+ n = match($0, /@[^@]+@/)
662662+ if (n) {
663663+ sub(/@[^@]+@/, "'$bold'" substr($0, RSTART + 1, RLENGTH - 2) "'$nc'", $0)
664664+ }
665665+ }
666666+667667+ if (/__[^_]+__/) {
668668+ n = match($0, /__[^_]+__/)
669669+ if (n) {
670670+ sub(/__[^_]+__/, "'$uline'" substr($0, RSTART + 2, RLENGTH - 4) "'$nc'", $0)
671671+ }
672672+ }
673673+674674+ s[++len] = $0
675675+ }
676676+677677+ END {
678678+ for (i = 1; i <= len; i++) {
679679+ if ((i == 1 || i == len) && (s[i] == "")) {
680680+ continue
681681+ }
682682+683683+ if (s[i] == "") {
684684+ print
685685+ } else {
686686+ '$log'("fin", s[i])
687687+ }
688688+ }
689689+ }
690690+691691+ ' > "$fd"
692692+end
693693+694694+695695+function __fin_log_error_footer -a fd
696696+ set -l url "https://github.com/fishery/fin/issues"
697697+ set -l debug_log "$fin_cache/fin-debug.log"
698698+699699+ __fin_log error "
700700+ For more help, visit the issue tracker
701701+ @$url@
702702+ ``
703703+ Include the following file with your issue
704704+ @$debug_log@
705705+ " $fd
706706+end
707707+708708+709709+function __fin_jobs_get
710710+ jobs $argv | command awk -v FS=\t '
711711+ /[0-9]+\t/{
712712+ jobs[++job_count] = $1
713713+ }
714714+715715+ END {
716716+ for (i = 1; i <= job_count; i++) {
717717+ print(jobs[i])
718718+ }
719719+720720+ exit job_count == 0
721721+ }
722722+ '
723723+end
724724+725725+726726+function __fin_jobs_await
727727+ if test -z "$argv"
728728+ return
729729+ end
730730+731731+ while true
732732+ for spinner in $fin_spinners
733733+ printf " $spinner \r" > /dev/stderr
734734+ sleep 0.04
735735+ end
736736+737737+ set -l currently_active_jobs (__fin_jobs_get)
738738+739739+ if test -z "$currently_active_jobs"
740740+ break
741741+ end
742742+743743+ set -l has_jobs
744744+745745+ for i in $argv
746746+ if builtin contains -- $i $currently_active_jobs
747747+ set has_jobs "*"
748748+ break
749749+ end
750750+ end
751751+752752+ if test -z "$has_jobs"
753753+ break
754754+ end
755755+ end
756756+end
757757+758758+759759+function __fin_key_bindings_remove -a plugin_name
760760+ set -l user_key_bindings "$fish_config/functions/fish_user_key_bindings.fish"
761761+ set -l tmp (date "+%s")
762762+763763+ fish_indent < "$user_key_bindings" | sed -n "/### $plugin_name ###/,/### $plugin_name ###/{s/^ *bind /bind -e /p;};" > shit #| source ^ /dev/null
764764+765765+ sed "/### $plugin_name ###/,/### $plugin_name ###/d" < "$user_key_bindings" > "$user_key_bindings.$tmp"
766766+ command mv -f "$user_key_bindings.$tmp" "$user_key_bindings"
767767+768768+ if awk '
769769+ /^$/ { next }
770770+771771+ /^function fish_user_key_bindings/ {
772772+ i++
773773+ next
774774+ }
775775+776776+ /^end$/ && 1 == i {
777777+ exit 0
778778+ }
779779+780780+ // {
781781+ exit 1
782782+ }
783783+784784+ ' < "$user_key_bindings"
785785+786786+ command rm -f "$user_key_bindings"
787787+ end
788788+end
789789+790790+791791+function __fin_key_bindings_append -a plugin_name file
792792+ set -l user_key_bindings "$fish_config/functions/fish_user_key_bindings.fish"
793793+794794+ command mkdir -p (dirname "$user_key_bindings")
795795+ touch "$user_key_bindings"
796796+797797+ set -l key_bindings_source (
798798+ fish_indent < "$user_key_bindings" | awk '
799799+800800+ /^function fish_user_key_bindings/ {
801801+ reading_function_source = 1
802802+ next
803803+ }
804804+805805+ /^end$/ {
806806+ exit
807807+ }
808808+809809+ reading_function_source {
810810+ print $0
811811+ next
812812+ }
813813+814814+ '
815815+ )
816816+817817+ set -l plugin_key_bindings_source (
818818+ fish_indent < "$file" | awk -v name="$plugin_name" '
819819+820820+ BEGIN {
821821+ printf("### %s ###\n", name)
822822+ }
823823+824824+ END {
825825+ printf("### %s ###\n", name)
826826+ }
827827+828828+ /^function fish_user_key_bindings$/ {
829829+ check_for_and_keyword = 1
830830+ next
831831+ }
832832+833833+ /^end$/ && check_for_and_keyword {
834834+ end = 0
835835+ next
836836+ }
837837+838838+ !/^ *(#.*)*$/ {
839839+ gsub("#.*", "")
840840+ printf("%s\n", $0)
841841+ }
842842+843843+ '
844844+ )
845845+846846+ printf "%s\n" $key_bindings_source $plugin_key_bindings_source | awk '
847847+848848+ BEGIN {
849849+ print "function fish_user_key_bindings"
850850+ }
851851+852852+ //
853853+854854+ END {
855855+ print "end"
856856+ }
857857+858858+ ' | fish_indent > "$user_key_bindings"
859859+end
860860+861861+862862+function __fin_plugin_is_prompt -a path
863863+ if test -e $path/fish_prompt.fish
864864+ return
865865+ end
866866+867867+ if test -e $path/functions/fish_prompt.fish
868868+ return
869869+ end
870870+871871+ if test -e $path/fish_right_prompt.fish
872872+ return
873873+ end
874874+875875+ if test -e $path/functions/fish_right_prompt.fish
876876+ return
877877+ end
878878+879879+ return 1
880880+end
881881+882882+883883+function __fin_plugin_get_names
884884+ printf "%s\n" $argv | command awk '
885885+886886+ {
887887+ sub(/\/$/, "")
888888+ n = split($0, s, "/")
889889+ sub(/^(omf|omf-theme|omf-plugin|plugin|theme|fish|fisher)-/, "", s[n])
890890+891891+ printf("%s\n%s\n", s[n], s[n - 1])
892892+ }
893893+894894+ '
895895+end
896896+897897+898898+function __fin_plugin_get_url_info -a option
899899+ set -e argv[1]
900900+901901+ if test -z "$argv"
902902+ return
903903+ end
904904+905905+ cat {$argv}/.git/config ^ /dev/null | command awk -v option="$option" '
906906+ /url/ {
907907+ n = split($3, s, "/")
908908+909909+ if ($3 ~ /https:\/\/gist/) {
910910+ printf("# %s\n", $3)
911911+ next
912912+ }
913913+914914+ if (option == "--dirname") {
915915+ printf("%s\n", s[n - 1])
916916+917917+ } else if (option == "--basename") {
918918+ printf("%s\n", s[n])
919919+920920+ } else {
921921+ printf("%s/%s\n", s[n - 1], s[n])
922922+ }
923923+ }
924924+ '
925925+end
926926+927927+928928+function __fin_plugin_normalize_path
929929+ printf "%s\n" $argv | command awk -v pwd="$PWD" '
930930+931931+ /^\.$/ {
932932+ print(pwd)
933933+ next
934934+ }
935935+936936+ /^\// {
937937+ sub(/\/$/, "")
938938+ print($0)
939939+ next
940940+ }
941941+942942+ {
943943+ sub(/\/$/, "")
944944+ n = split($0, a, "/")
945945+ print(pwd "/" (n > 1 ? a[n - 1] "/" : "") a[n])
946946+947947+ next
948948+ }
949949+950950+ '
951951+end
952952+953953+954954+function __fin_plugin_get_missing
955955+ for i in $argv
956956+ if test -d "$i"
957957+ set i (__fin_plugin_normalize_path "$i")
958958+ end
959959+960960+ set -l name (__fin_plugin_get_names "$i")[1]
961961+962962+ if set -l path (__fin_plugin_is_installed "$name")
963963+ for file in fishfile bundle
964964+ if test -s "$path/$file"
965965+ __fin_plugin_get_missing (__fin_read_bundle_file < "$path/$file")
966966+ end
967967+ end
968968+ else
969969+ printf "%s\n" "$i"
970970+ end
971971+ end
972972+973973+ __fin_show_spinner
974974+end
975975+976976+977977+function __fin_plugin_is_installed -a name
978978+ if test -z "$name" -o ! -d "$fin_config/$name"
979979+ return 1
980980+ end
981981+982982+ printf "%s\n" "$fin_config/$name"
983983+end
984984+985985+986986+function __fin_reset_default_fish_colors
987987+ set -U fish_color_normal normal
988988+ set -U fish_color_command 005fd7 purple
989989+ set -U fish_color_param 00afff cyan
990990+ set -U fish_color_redirection 005fd7
991991+ set -U fish_color_comment 600
992992+ set -U fish_color_error red --bold
993993+ set -U fish_color_escape cyan
994994+ set -U fish_color_operator cyan
995995+ set -U fish_color_end green
996996+ set -U fish_color_quote brown
997997+ set -U fish_color_autosuggestion 555 yellow
998998+ set -U fish_color_user green
999999+ set -U fish_color_valid_path --underline
10001000+ set -U fish_color_cwd green
10011001+ set -U fish_color_cwd_root red
10021002+ set -U fish_color_match cyan
10031003+ set -U fish_color_search_match --background=purple
10041004+ set -U fish_color_selection --background=purple
10051005+ set -U fish_pager_color_prefix cyan
10061006+ set -U fish_pager_color_completion normal
10071007+ set -U fish_pager_color_description 555 yellow
10081008+ set -U fish_pager_color_progress cyan
10091009+ set -U fish_color_history_current cyan
10101010+ set -U fish_color_host normal
10111011+end
10121012+10131013+10141014+function __fin_read_bundle_file
10151015+ command awk -v FS=\t '
10161016+ /^$/ || /^[ \t]*#/ {
10171017+ next
10181018+ }
10191019+10201020+ /^[ \t]*package / {
10211021+ sub("^[ \t]*package ", "oh-my-fish/plugin-")
10221022+ }
10231023+10241024+ {
10251025+ sub("^[@* \t]*", "")
10261026+10271027+ if (!seen[$0]++) {
10281028+ printf("%s\n", $0)
10291029+ }
10301030+ }
10311031+ '
10321032+end
10331033+10341034+10351035+function __fin_completions_write
10361036+ functions __fin_completions_write | fish_indent | __fin_parse_comments_from_function
10371037+10381038+ # complete -xc fin -s h -l help -d "Show usage help"
10391039+ # complete -xc fin -s q -l quiet -d "Enable quiet mode"
10401040+ # complete -xc fin -s v -l version -d "Show version information"
10411041+ # complete -xc fin -n "__fish_use_subcommand" -a install -d "Install plugins / i"
10421042+ # complete -xc fin -n "__fish_use_subcommand" -a update -d "Update fin and plugins / u"
10431043+ # complete -xc fin -n "__fish_use_subcommand" -a rm -d "Remove plugins / r"
10441044+ # complete -xc fin -n "__fish_use_subcommand" -a ls -d "List plugins / l"
10451045+ # complete -xc fin -n "__fish_use_subcommand" -a help -d "Show help / h"
10461046+end
10471047+10481048+10491049+function __fin_humanize_duration
10501050+ awk '
10511051+ function hmTime(time, stamp) {
10521052+ split("h:m:s:ms", units, ":")
10531053+10541054+ for (i = 2; i >= -1; i--) {
10551055+ if (t = int( i < 0 ? time % 1000 : time / (60 ^ i * 1000) % 60 )) {
10561056+ stamp = stamp t units[sqrt((i - 2) ^ 2) + 1] " "
10571057+ }
10581058+ }
10591059+10601060+ if (stamp ~ /^ *$/) {
10611061+ return "0ms"
10621062+ }
10631063+10641064+ return substr(stamp, 1, length(stamp) - 1)
10651065+ }
10661066+10671067+ {
10681068+ print hmTime($0)
10691069+ }
10701070+ '
10711071+end
10721072+10731073+10741074+function __fin_get_key
10751075+ stty -icanon -echo ^ /dev/null
10761076+10771077+ printf "$argv" > /dev/stderr
10781078+10791079+ while true
10801080+ dd bs=1 count=1 ^ /dev/null | read -p "" -l yn
10811081+10821082+ switch "$yn"
10831083+ case y Y n N
10841084+ printf "\n" > /dev/stderr
10851085+ printf "%s\n" $yn > /dev/stdout
10861086+ break
10871087+ end
10881088+ end
10891089+10901090+ stty icanon echo > /dev/stderr ^ /dev/null
10911091+end
10921092+10931093+10941094+function __fin_get_epoch_in_ms -a elapsed
10951095+ if test -z "$elapsed"
10961096+ set elapsed 0
10971097+ end
10981098+10991099+ perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - '$elapsed')'
11001100+end
11011101+11021102+11031103+function __fin_parse_column_output
11041104+ command awk -v FS=\t '
11051105+ {
11061106+11071107+ for (i = 1; i <= NF; i++) {
11081108+ if ($i != "") {
11091109+ print $i
11101110+ }
11111111+ }
11121112+11131113+ }
11141114+ '
11151115+end
11161116+11171117+11181118+function __fin_parse_comments_from_function
11191119+ command awk '
11201120+11211121+ /^[\t ]*# ?/ {
11221122+ sub(/^[\t ]*# ?/, "")
11231123+ a[++n] = $0
11241124+ }
11251125+11261126+ END {
11271127+ for (i = 1; i <= n; i++) {
11281128+ printf("%s\n", a[i])
11291129+ }
11301130+ }
11311131+11321132+ '
11331133+end
11341134+11351135+11361136+function __fin_usage
11371137+ set -l u (set_color -u)
11381138+ set -l nc (set_color normal)
11391139+11401140+ echo "Usage: fin [<command>] [<plugins>] [--quiet] [--version]"
11411141+ echo
11421142+ echo "where <command> can be one of:"
11431143+ echo " "$u"i"$nc"nstall (default)"
11441144+ echo " "$u"u"$nc"pdate"
11451145+ echo " "$u"r"$nc"m"
11461146+ echo " "$u"l"$nc"s"
11471147+ echo " "$u"h"$nc"elp"
11481148+end
11491149+11501150+11511151+function __fin_help -a command number
11521152+ if test -z "$argv"
11531153+ set -l page "$fin_cache/fin.1"
11541154+11551155+ if test ! -s "$page"
11561156+ __fin_man_page_write > "$page"
11571157+ end
11581158+11591159+ set -l pager "/usr/bin/less -s"
11601160+11611161+ if test ! -z "$PAGER"
11621162+ set pager "$PAGER"
11631163+ end
11641164+11651165+ man -P "$pager" -- "$page"
11661166+11671167+ command rm -f "$page"
11681168+11691169+ else
11701170+ if test -z "$number"
11711171+ set number 1
11721172+ end
11731173+11741174+ set -l page "$fin_config/$command/man/man$number/$command.$number"
11751175+11761176+ if not man "$page" ^ /dev/null
11771177+ __fin_log error "No manual entry for $command" $__fin_stderr
11781178+11791179+ if test -d "$fin_config/$command"
11801180+ set -l url (__fin_plugin_get_url_info -- $fin_config/$command)
11811181+11821182+ if test ! -z "$url"
11831183+ __fin_log says "Visit the online repository for help:" $__fin_stderr
11841184+ __fin_log says "__https://github.com/$url" $__fin_stderr
11851185+ end
11861186+ else
11871187+ __fin_log error "$command is not installed" $__fin_stderr
11881188+ end
11891189+11901190+ return 1
11911191+ end
11921192+ end
11931193+end
11941194+11951195+11961196+function __fin_man_page_write
11971197+ functions __fin_man_page_write | fish_indent | __fin_parse_comments_from_function
11981198+11991199+ # .
12001200+ # .TH "FIN" "1" "April 2016" "" "fin"
12011201+ # .
12021202+ # .SH "NAME"
12031203+ # \fBfin\fR \- fish plugin manager
12041204+ # .
12051205+ # .SH "SYNOPSIS"
12061206+ # fin [\fIcommand\fR] [\fIplugins\fR] [\-\-quiet] [\-\-version]
12071207+ # .
12081208+ # .br
12091209+ # .
12101210+ # .SH "DESCRIPTION"
12111211+ # fin is a one\-file, no\-configuration, concurrent plugin manager for the fish shell\.
12121212+ # .
12131213+ # .SH "USAGE"
12141214+ # Install a plugin\.
12151215+ # .
12161216+ # .IP "" 4
12171217+ # .
12181218+ # .nf
12191219+ #
12201220+ # fin superman
12211221+ # .
12221222+ # .fi
12231223+ # .
12241224+ # .IP "" 0
12251225+ # .
12261226+ # .P
12271227+ # Install from multiple sources\.
12281228+ # .
12291229+ # .IP "" 4
12301230+ # .
12311231+ # .nf
12321232+ #
12331233+ # fin omf/{grc,thefuck} fzf z
12341234+ # .
12351235+ # .fi
12361236+ # .
12371237+ # .IP "" 0
12381238+ # .
12391239+ # .P
12401240+ # Install from a URL\.
12411241+ # .
12421242+ # .IP "" 4
12431243+ # .
12441244+ # .nf
12451245+ #
12461246+ # fin https://github\.com/edc/bass
12471247+ # .
12481248+ # .fi
12491249+ # .
12501250+ # .IP "" 0
12511251+ # .
12521252+ # .P
12531253+ # Install from a gist\.
12541254+ # .
12551255+ # .IP "" 4
12561256+ # .
12571257+ # .nf
12581258+ #
12591259+ # fin https://gist\.github\.com/username/1f40e1c6e0551b2666b2
12601260+ # .
12611261+ # .fi
12621262+ # .
12631263+ # .IP "" 0
12641264+ # .
12651265+ # .P
12661266+ # Install from a local directory\.
12671267+ # .
12681268+ # .IP "" 4
12691269+ # .
12701270+ # .nf
12711271+ #
12721272+ # fin ~/my_aliases
12731273+ # .
12741274+ # .fi
12751275+ # .
12761276+ # .IP "" 0
12771277+ # .
12781278+ # .P
12791279+ # Use it a la vundle\. Edit \fB~/\.config/fish/bundle\fR and run \fBfin\fR to satisfy the changes\.
12801280+ # .
12811281+ # .IP "" 4
12821282+ # .
12831283+ # .nf
12841284+ #
12851285+ # $EDITOR ~/\.config/fish/bundle # add plugins
12861286+ # fin
12871287+ # .
12881288+ # .fi
12891289+ # .
12901290+ # .IP "" 0
12911291+ # .
12921292+ # .P
12931293+ # See what\'s installed\.
12941294+ # .
12951295+ # .IP "" 4
12961296+ # .
12971297+ # .nf
12981298+ #
12991299+ # fin ls
13001300+ # @ my_aliases # this plugin is a local directory
13011301+ # * superman # this plugin is the current prompt
13021302+ # bass
13031303+ # fzf
13041304+ # grc
13051305+ # thefuck
13061306+ # z
13071307+ # .
13081308+ # .fi
13091309+ # .
13101310+ # .IP "" 0
13111311+ # .
13121312+ # .P
13131313+ # Update everything\.
13141314+ # .
13151315+ # .IP "" 4
13161316+ # .
13171317+ # .nf
13181318+ #
13191319+ # fin update
13201320+ # .
13211321+ # .fi
13221322+ # .
13231323+ # .IP "" 0
13241324+ # .
13251325+ # .P
13261326+ # Update some plugins\.
13271327+ # .
13281328+ # .IP "" 4
13291329+ # .
13301330+ # .nf
13311331+ #
13321332+ # fin update bass z fzf thefuck
13331333+ # .
13341334+ # .fi
13351335+ # .
13361336+ # .IP "" 0
13371337+ # .
13381338+ # .P
13391339+ # Remove plugins\.
13401340+ # .
13411341+ # .IP "" 4
13421342+ # .
13431343+ # .nf
13441344+ #
13451345+ # fin rm superman
13461346+ # .
13471347+ # .fi
13481348+ # .
13491349+ # .IP "" 0
13501350+ # .
13511351+ # .P
13521352+ # Remove everything\.
13531353+ # .
13541354+ # .IP "" 4
13551355+ # .
13561356+ # .nf
13571357+ #
13581358+ # fin ls | fin rm
13591359+ # .
13601360+ # .fi
13611361+ # .
13621362+ # .IP "" 0
13631363+ # .
13641364+ # .P
13651365+ # Get help\.
13661366+ # .
13671367+ # .IP "" 4
13681368+ # .
13691369+ # .nf
13701370+ #
13711371+ # fin help z
13721372+ # .
13731373+ # .fi
13741374+ # .
13751375+ # .IP "" 0
13761376+ # .
13771377+ # .SH "FAQ"
13781378+ # .
13791379+ # .SS "1\. How do I uninstall fin?"
13801380+ # Run
13811381+ # .
13821382+ # .IP "" 4
13831383+ # .
13841384+ # .nf
13851385+ #
13861386+ # fin self\-destroy
13871387+ # .
13881388+ # .fi
13891389+ # .
13901390+ # .IP "" 0
13911391+ # .
13921392+ # .SS "2\. What fish version is required?"
13931393+ # fin was built for the latest fish, but at least 2\.2\.0 is required\. If you can\'t upgrade your build, append the following code to your \fB~/\.config/fish/config\.fish\fR for snippet \fIhttps://github\.com/fishery/fin/blob/master/faq\.md#12\-what\-is\-a\-plugin\fR support\.
13941394+ # .
13951395+ # .IP "" 4
13961396+ # .
13971397+ # .nf
13981398+ #
13991399+ # for file in ~/\.config/fish/conf\.d/*\.fish
14001400+ # source $file
14011401+ # end
14021402+ # .
14031403+ # .fi
14041404+ # .
14051405+ # .IP "" 0
14061406+ # .
14071407+ # .SS "3\. Is fin compatible with fisherman and oh my fish themes and plugins?"
14081408+ # Yes\.
14091409+ # .
14101410+ # .SS "4\. Why fin? Why not ____?"
14111411+ # fin learns from my mistakes building oh my fish, wahoo and fisherman\. It also takes some ideas from fundle and chips\.
14121412+ # .
14131413+ # .P
14141414+ # Other reasons:
14151415+ # .
14161416+ # .IP "\(bu" 4
14171417+ # fast and easy to install, update and uninstall
14181418+ # .
14191419+ # .IP "\(bu" 4
14201420+ # small and fits in one file
14211421+ # .
14221422+ # .IP "\(bu" 4
14231423+ # you don\'t need to modify your fish configuration to use it
14241424+ # .
14251425+ # .IP "\(bu" 4
14261426+ # framework agnostic, no favorites
14271427+ # .
14281428+ # .IP "\(bu" 4
14291429+ # zero impact on shell startup time
14301430+ # .
14311431+ # .IP "" 0
14321432+ # .
14331433+ # .SS "5\. Where does fin put stuff?"
14341434+ # fin usually goes in \fB~/\.config/fish/functions/fin\.fish\fR\.
14351435+ # .
14361436+ # .P
14371437+ # The cache and plugin configuration is created in \fB~/\.cache/fin\fR and \fB~/\.config/fin\fR respectively\.
14381438+ # .
14391439+ # .P
14401440+ # The \fBbundle\fR file is stored in \fB~/\.config/fish\fR\.
14411441+ # .
14421442+ # .SS "6\. What is a bundle file and how do I use it?"
14431443+ # The bundle file lists all the installed plugins\.
14441444+ # .
14451445+ # .P
14461446+ # You can let fin take care of the bundle for you automatically, or write in the plugins you want and run \fBfin\fR to satisfy the changes\.
14471447+ # .
14481448+ # .IP "" 4
14491449+ # .
14501450+ # .nf
14511451+ #
14521452+ # fishery/superman
14531453+ # omf/grc
14541454+ # omf/thefuck
14551455+ # fishery/z
14561456+ # .
14571457+ # .fi
14581458+ # .
14591459+ # .IP "" 0
14601460+ # .
14611461+ # .P
14621462+ # This mechanism only installs plugins and missing dependencies\. To remove a plugin, use \fBfin rm\fR instead\.
14631463+ # .
14641464+ # .P
14651465+ # The bundle file is inside your fish configuration directory \fB~/\.config/fish\fR so you can commit the entire tree to your dotfiles or only the bundle and that\'s it\.
14661466+ # .
14671467+ # .SS "7\. Where can I find a list of fish plugins?"
14681468+ # Browse github/fishery, github/oh\-my\-fish, github/awesome\-fish or use the http://fisherman.sh online search to discover content\.
14691469+ # .
14701470+ # .SS "8\. How do I install, update, list or remove plugins?"
14711471+ # See \fIUsage\fR\.
14721472+ # .
14731473+ # .SS "9\. How do I upgrade from ___?"
14741474+ # You don\'t have to\. fin is framework agnostic and does not interfere with other known systems\. If you want to uninstall oh my fish or fisherman, refer to their documentation\.
14751475+ # .
14761476+ # .SS "10\. How do I update fin to the latest version?"
14771477+ # Run
14781478+ # .
14791479+ # .IP "" 4
14801480+ # .
14811481+ # .nf
14821482+ #
14831483+ # fin update
14841484+ # .
14851485+ # .fi
14861486+ # .
14871487+ # .IP "" 0
14881488+ # .
14891489+ # .SS "12\. What is a plugin?"
14901490+ # A plugin is:
14911491+ # .
14921492+ # .IP "1." 4
14931493+ # a directory or git repo with a function \fB\.fish\fR file either at the root level of the project or inside a \fBfunctions\fR directory
14941494+ # .
14951495+ # .IP "2." 4
14961496+ # a theme or prompt, i\.e, a \fBfish_prompt\.fish\fR, \fBfish_right_prompt\.fish\fR or both files
14971497+ # .
14981498+ # .IP "3." 4
14991499+ # a snippet, i\.e, one or more \fB\.fish\fR files inside a directory named \fBconf\.d\fR that are evaluated by fish at the start of the shell
15001500+ # .
15011501+ # .IP "" 0
15021502+ # .
15031503+ # .SS "13\. How can I list plugins as dependencies to my plugin?"
15041504+ # Create a new \fBbundle\fR file at the root level of your project and write in the plugin dependencies:
15051505+ # .
15061506+ # .IP "" 4
15071507+ # .
15081508+ # .nf
15091509+ #
15101510+ # owner/repo
15111511+ # https://github\.com/dude/sweet
15121512+ # https://gist\.github\.com/bucaran/c256586044fea832e62f02bc6f6daf32
15131513+ # .
15141514+ # .fi
15151515+ # .
15161516+ # .IP "" 0
15171517+ # .
15181518+ # .SS "14\. I have a question or request not addressed here\. Where should I put it?"
15191519+ # Create a new ticket on the issue tracker:
15201520+ # .
15211521+ # .IP "\(bu" 4
15221522+ # https://github\.com/fishery/fin/issues
15231523+ # .
15241524+ # .IP "" 0
15251525+ # .
15261526+ # .SS "15\. Why did you create a new project instead of improving fisherman?"
15271527+ # .
15281528+ # .IP "1." 4
15291529+ # fisherman uses an index file and has built\-in search capabilities / advanced completions that are not compatible with fin\'s simpler model
15301530+ # .
15311531+ # .IP "2." 4
15321532+ # I wanted a clean slate and a chance to experiment with something different
15331533+ # .
15341534+ # .IP "3." 4
15351535+ # fin is more opinionated and pragmatic than fisherman, thus truer to fish configurability principle
15361536+ # .
15371537+ # .IP "" 0
15381538+ # .
15391539+ # .SS "16\. What about chips and fundle?"
15401540+ # chips is far from ready and it\'s not written in fish either\. fundle inspired me to use a bundle and one\-file distribution, but it has limited capabilities and still requires you to edit your fish configuration\.
15411541+ # .
15421542+ # .SS "17\. Does this mean you are done with fisherman?"
15431543+ # Nope\.
15441544+ # .
15451545+ # .SH "BUGS"
15461546+ # When you find issues, please report them:
15471547+ # .
15481548+ # .IP "\(bu" 4
15491549+ # \fIhttp://github\.com/fishery/fin/issues\fR
15501550+ # .
15511551+ # .IP "" 0
15521552+ # .
15531553+ # .P
15541554+ # Be sure to include all of the output from fin that didn\'t work as expected\.
15551555+ # .
15561556+ # .SH "AUTHOR"
15571557+ # Fisherman was created by Jorge Bucaran :: @bucaran :: j@bucaran\.me
15581558+ # .
15591559+ # .P
15601560+ # See the contributor graph for a list of other people who have contributed to this project:
15611561+ # .
15621562+ # .IP "\(bu" 4
15631563+ # \fIhttps://github\.com/fishery/fin/graphs/contributors\fR
15641564+ # .
15651565+ # .IP "" 0
15661566+end
15671567+15681568+15691569+function __fin_self_destroy
15701570+ if test -z "$fish_config" -o -z "$fin_cache" -o -z "$fin_config" -o -L "$fin_cache" -o -L "$fin_config"
15711571+ __fin_log error "
15721572+15731573+ Some of fin variables refer to symbolic links or were undefined.
15741574+15751575+ If you are running a custom fin setup, remove the following
15761576+ directories and files by yourself:
15771577+15781578+ @$fin_cache@
15791579+ @$fin_config@
15801580+ @$fish_config/functions/fin.fish@
15811581+ @$fish_config/completions/fin.fish@
15821582+15831583+ " /dev/stderr
15841584+15851585+ __fin_log_error_footer /dev/stderr
15861586+15871587+ return 1
15881588+ end
15891589+15901590+ set -l u (set_color -u)
15911591+ set -l nc (set_color normal)
15921592+15931593+ switch "$argv"
15941594+ case -y --yes
15951595+ case \*
15961596+ __fin_log warn "
15971597+ This will permanently remove fin from your system.
15981598+ The following directories and files will be erased:
15991599+16001600+ @$fin_cache@
16011601+ @$fin_config@
16021602+ @$fish_config/functions/fin.fish@
16031603+ @$fish_config/completions/fin.fish@
16041604+16051605+ " /dev/stderr
16061606+16071607+ echo -sn "Do you wish to continue? [Y/n] " > /dev/stderr
16081608+16091609+ __fin_get_key | read -l yn
16101610+16111611+ switch "$yn"
16121612+ case n N
16131613+ set -l username
16141614+16151615+ if test ! -z "$USER"
16161616+ set username " $USER"
16171617+ end
16181618+16191619+ __fin_log okay "As you wish cap!"
16201620+ return 1
16211621+ end
16221622+ end
16231623+16241624+ complete -c fin --erase
16251625+16261626+ __fin_show_spinner
16271627+16281628+ fin ls | fin rm
16291629+16301630+ __fin_show_spinner
16311631+16321632+ command rm -rf "$fin_cache" "$fin_config"
16331633+ command rm -f "$fish_config/functions/fin.fish" "$fish_config/completions/fin.fish"
16341634+16351635+ __fin_show_spinner
16361636+16371637+ set -e fin_active_prompt
16381638+ set -e fin_cache
16391639+ set -e fin_config
16401640+ set -e fish_config
16411641+ set -e fin_bundle
16421642+ set -e fin_version
16431643+ set -e fin_spinners
16441644+16451645+ for func in __fin_jobs_await __fin_plugin_url_clone_async __fin_completions_write __fin_plugin_fetch_items __fin_get_epoch_in_ms __fin_jobs_get __fin_get_key __fin_get_plugin_name_from_gist __fin_plugin_get_names __fin_plugin_get_url_info __fin_plugin_get_missing __fin_help __fin_humanize_duration __fin_install __fin_list __fin_list_plugin_directory __fin_log_error_footer __fin_man_page_write __fin_plugin_normalize_path __fin_parse_column_output __fin_parse_comments_from_function __fin_plugin_is_prompt __fin_plugin_disable __fin_plugin_enable __fin_plugin_is_installed __fin_read_bundle_file __fin_reset_default_fish_colors __fin_self_destroy __fin_self_update __fin_usage __fin_update __fin_update_path_async
16461646+ __fin_show_spinner
16471647+ functions -e "$func"
16481648+ end
16491649+16501650+ __fin_show_spinner
16511651+16521652+ functions -e __fin_show_spinner
16531653+16541654+ __fin_log says "
16551655+16561656+ Thanks for trying out fin. If you have a moment,
16571657+ please share your feedback in our issue tracker.
16581658+16591659+ @https://github.com/fishery/fin/issues@
16601660+16611661+ " $__fin_stderr
16621662+16631663+ functions -e __fin_log
16641664+end
16651665+16661666+16671667+function fin
16681668+ set -g fin_spinners ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏
16691669+16701670+ function __fin_show_spinner
16711671+ if not set -q __fin_fg_spinner[1]
16721672+ set -g __fin_fg_spinner $fin_spinners
16731673+ end
16741674+16751675+ printf " $__fin_fg_spinner[1]\r" > /dev/stderr
16761676+16771677+ set -e __fin_fg_spinner[1]
16781678+ end
16791679+16801680+ set -l config_home $XDG_CONFIG_HOME
16811681+ set -l cache_home $XDG_CACHE_HOME
16821682+16831683+ if test -z "$config_home"
16841684+ set config_home ~/.config
16851685+ end
16861686+16871687+ if test -z "$cache_home"
16881688+ set cache_home ~/.cache
16891689+ end
16901690+16911691+ if test -z "$fish_config"
16921692+ set -g fish_config "$config_home/fish"
16931693+ end
16941694+16951695+ if test -z "$fin_config"
16961696+ set -g fin_config "$config_home/fin"
16971697+ end
16981698+16991699+ if test -z "$fin_cache"
17001700+ set -g fin_cache "$cache_home/fin"
17011701+ end
17021702+17031703+ if test -z "$fin_bundle"
17041704+ set -g fin_bundle "$fish_config/bundle"
17051705+ end
17061706+17071707+ if not command mkdir -p "$fish_config/"{conf.d,functions,completions} "$fin_config" "$fin_cache"
17081708+ __fin_log error "
17091709+ I couldn't create the fin configuration.
17101710+ You need write permissions in these directories:
17111711+17121712+ @$fish_config@
17131713+ @$fin_config@
17141714+ @$fin_cache@
17151715+ " > /dev/stderr
17161716+17171717+ return 1
17181718+ end
17191719+17201720+ set -l elapsed (__fin_get_epoch_in_ms)
17211721+17221722+ set -g __fin_stdout /dev/stdout
17231723+ set -g __fin_stderr /dev/stderr
17241724+17251725+ set -l command
17261726+17271727+ for flag in -q --quiet
17281728+ if set -l index (builtin contains --index -- $flag $argv)
17291729+ set -e argv[$index]
17301730+ set __fin_stdout /dev/null
17311731+ set __fin_stderr /dev/null
17321732+17331733+ break
17341734+ end
17351735+ end
17361736+17371737+ switch "$argv[1]"
17381738+ case i install
17391739+ set -e argv[1]
17401740+ set command "install"
17411741+17421742+ case u up update
17431743+ set -e argv[1]
17441744+ set command "update"
17451745+17461746+ case r rm remove uninstall
17471747+ set -e argv[1]
17481748+ set command "rm"
17491749+17501750+ case l ls list
17511751+ set -e argv[1]
17521752+ set command "ls"
17531753+17541754+ case h help
17551755+ set -e argv[1]
17561756+ __fin_help $argv
17571757+ return
17581758+17591759+ case -h
17601760+ __fin_usage > /dev/stderr
17611761+ return
17621762+17631763+ case --help
17641764+ __fin_help
17651765+ return
17661766+17671767+ case -v --version
17681768+ set -l home ~
17691769+ printf "fin v$fin_version %s\n" (__fin_plugin_normalize_path (status -f) | command awk -v home="$home" '{ sub(home, "~") } //')
17701770+ return
17711771+17721772+ case -- ""
17731773+ set -e argv[1]
17741774+17751775+ if test -z "$argv"
17761776+ set command "default"
17771777+ else
17781778+ set command "install"
17791779+ end
17801780+17811781+ case self-destroy
17821782+ set -e argv[1]
17831783+ __fin_self_destroy $argv
17841784+ return
17851785+17861786+ case -\*\?
17871787+ printf "fin: '%s' is not a valid option\n" "$argv[1]" > /dev/stderr
17881788+ __fin_usage > /dev/stderr
17891789+ return 1
17901790+17911791+ case \*
17921792+ set command "install"
17931793+ end
17941794+17951795+ set -l items (
17961796+ printf "%s\n" $argv | command awk '
17971797+17981798+ /^(--|-).*/ { next }
17991799+18001800+ /^omf\// {
18011801+ sub(/^omf\//, "oh-my-fish/")
18021802+18031803+ if ($0 !~ /(theme|plugin)-/) {
18041804+ sub(/^oh-my-fish\//, "oh-my-fish/plugin-")
18051805+ }
18061806+ }
18071807+18081808+ !seen[$0]++
18091809+18101810+ '
18111811+ )
18121812+18131813+ if test -z "$items" -a "$command" = "default"
18141814+ if isatty
18151815+ touch "$fin_bundle"
18161816+ set items (__fin_read_bundle_file < "$fin_bundle")
18171817+ set command "install"
18181818+18191819+ if test -z "$items"
18201820+ __fin_log warn "
18211821+ The bundle file is empty.
18221822+ @$fish_config/bundle@
18231823+ " $__fin_stderr
18241824+18251825+ __fin_log says "
18261826+18271827+ Your bundle keeps track of what's currently installed.
18281828+ Write in the plugins you want and run fin again to
18291829+ satisfy changes.
18301830+18311831+ You can also install plugins using @fin plugin1 ...@
18321832+ " $__fin_stderr
18331833+18341834+ return 1
18351835+ end
18361836+ end
18371837+ end
18381838+18391839+ switch "$command"
18401840+ case install
18411841+ if __fin_install $items
18421842+ __fin_log says "Done in "(__fin_get_epoch_in_ms $elapsed | __fin_humanize_duration) $__fin_stderr
18431843+ end
18441844+18451845+ case update
18461846+ if isatty
18471847+ if test -z "$items"
18481848+ __fin_self_update
18491849+18501850+ set items (__fin_list | command sed 's/^[@* ]*//')
18511851+ end
18521852+ else
18531853+ __fin_parse_column_output | __fin_read_bundle_file | read -laz _items
18541854+ set items $items $_items
18551855+ end
18561856+18571857+ __fin_update $items
18581858+18591859+ __fin_log says "Done in "(__fin_get_epoch_in_ms $elapsed | __fin_humanize_duration) $__fin_stderr
18601860+18611861+ case ls
18621862+ if test "$argv" -ge 0 -o "$argv" = -
18631863+ set items (__fin_list)
18641864+18651865+ set -l count (count $items)
18661866+18671867+ if test "$count" -ge 10
18681868+ printf "%s\n" $items | column -c$argv
18691869+18701870+ else if test "$count" -ge 1
18711871+ printf "%s\n" $items
18721872+ end
18731873+18741874+ else
18751875+ __fin_list_plugin_directory $argv
18761876+ end
18771877+18781878+ case rm
18791879+ if test -z "$items"
18801880+ __fin_parse_column_output | __fin_read_bundle_file | read -az items
18811881+ end
18821882+18831883+ if test (count $items) -le 1
18841884+ function __fin_show_spinner
18851885+ end
18861886+ end
18871887+18881888+ if test ! -z "$items"
18891889+ for i in $items
18901890+ set -l name (__fin_plugin_get_names "$i")[1]
18911891+ __fin_plugin_disable "$fin_config/$name"
18921892+ __fin_show_spinner
18931893+ end
18941894+ end
18951895+18961896+ __fin_log says "Done in "(__fin_get_epoch_in_ms $elapsed | __fin_humanize_duration) $__fin_stderr
18971897+ end
18981898+18991899+ complete -c fin --erase
19001900+19011901+ set -l config $fin_config/*
19021902+ set -l cache $fin_cache/*
19031903+19041904+ if test -z "$config"
19051905+ echo > $fin_bundle
19061906+ else
19071907+ __fin_plugin_get_url_info -- $config > $fin_bundle
19081908+19091909+ complete -xc fin -n "__fish_seen_subcommand_from u up update r rm remove uninstall" -a "(printf '%s\n' $config | command sed 's|.*/||')"
19101910+ complete -xc fin -n "__fish_seen_subcommand_from u up update r rm remove uninstall" -a "$fin_active_prompt" -d "Prompt"
19111911+ end
19121912+19131913+ if test ! -z "$cache"
19141914+ printf "%s\n" $cache | command awk -v _config="$config" '
19151915+19161916+ BEGIN {
19171917+ count = split(_config, config, " ")
19181918+ }
19191919+19201920+ {
19211921+ sub(/.*\//, "")
19221922+19231923+ for (i = 1; i <= count; i++) {
19241924+ sub(/.*\//, "", config[i])
19251925+19261926+ if (config[i] == $0) {
19271927+ next
19281928+ }
19291929+ }
19301930+ }
19311931+19321932+ //
19331933+19341934+ ' | while read -l plugin
19351935+ if __fin_plugin_is_prompt "$fin_cache/$plugin"
19361936+ complete -xc fin -n "__fish_seen_subcommand_from i in install" -a "$plugin" -d "Prompt"
19371937+ complete -xc fin -n "not __fish_seen_subcommand_from u up update r rm remove uninstall l ls list h help" -a "$plugin" -d "Prompt"
19381938+ else
19391939+ complete -xc fin -n "__fish_seen_subcommand_from i in install" -a "$plugin" -d "Plugin"
19401940+ complete -xc fin -n "not __fish_seen_subcommand_from u up update r rm remove uninstall l ls list h help" -a "$plugin" -d "Plugin"
19411941+ end
19421942+ end
19431943+ end
19441944+19451945+ set -l completions "$fish_config/completions/fin.fish"
19461946+19471947+ if test ! -e "$completions"
19481948+ __fin_completions_write > "$completions"
19491949+ source "$completions"
19501950+ end
19511951+end
···11-augroup format
22- au!
33- au BufWritePost *.rb :RubocopFmt
44-augroup END
11+command! RubocopFmt NeomakeSh rubocop -a %
5266-command! RubocopFmt NeomakeSh rubocop -la %
33+ClearSwapList
7488-noremap <leader>rb :up<bar>call VimuxRunCommand("clear; cargo bench")<CR>
99-noremap <leader>rr :up<bar>call VimuxRunCommand("clear; cargo test")<CR>
55+SwapList visibility public protected private
66+SwapList if if unless
77+SwapList while while until
···11+" Line numbers are good
22+augroup numbers
33+ au BufEnter,WinEnter * set number
44+ au BufEnter,WinEnter * set relativenumber
55+ au BufLeave,WinLeave * set nonumber
66+ au BufLeave,WinLeave * set norelativenumber
77+augroup END
···1414# Background 256 color coding:
1515# 48;5;COLOR_NUMBER
16161717-NORMAL 00;38;5;19 # no color code at all
1717+NORMAL 00;38;5;01 # no color code at all
1818#FILE 00 # regular file: use no color at all
1919RESET 0 # reset to "normal" color
2020DIR 00;38;5;04 # directory 01;34
···156156.coffee 01;38;5;11
157157.ts 01;38;5;11
158158.nix 01;38;5;13
159159+.ex 01;38;5;01
160160+.exs 01;38;5;01
159161# }}}
160162# Documentation {{{
161163.md 01;38;5;07