-
Notifications
You must be signed in to change notification settings - Fork 0
/
fisher.fish
2520 lines (1970 loc) · 61.1 KB
/
fisher.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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
if not set -q fisher_cmd_name
status --current-filename | command awk '
{
if (n = split($0, parts, "/")) {
gsub(/\.fish$/, "", parts[n])
print(parts[n])
}
}
' | read -gx fisher_cmd_name
end
if test -z "$fisher_cmd_name"
set -gx fisher_cmd_name "fisher"
end
function $fisher_cmd_name -d "fish plugin manager"
switch "$FISH_VERSION"
case 2.1.2 2.1.1 2.1.0 2.0.0
echo "You need fish 2.2.0 or higher to use fisherman."
if type brew >/dev/null 2>&1
echo "Run: brew upgrade fish"
else
echo "
Refer to your package manager documentation for
instructions on how to upgrade your fish build.
"
end
return 1
case 2.2.0
__fisher_log info "
You need fish 2.3.0 or higher to take advantage of snippets.
Without it some plugins might not work.
"
if type -q brew
__fisher_log info "Please run &brew upgrade fish&"
else
__fisher_log info "
Refer to your package manager documentation
for instructions on how to upgrade your fish build.
If you can not upgrade, append the following code
to your ~/.config/fish/config.fish:
&for file in ~/.config/fish/conf.d/*.fish&
&source \$file&
&end&
"
end
end
set -g fisher_version "2.13.3"
set -g fisher_spinners ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏
if [ -e /dev/stdout ]
set -g __fisher_stdout /dev/stdout
else if [ -e /proc/self/fd/1 ]
set -g __fisher_stdout /proc/self/fd/1
else
echo "No suitable stdout"
return 1
end
if [ -e /dev/stderr ]
set -g __fisher_stderr /dev/stderr
else if [ -e /proc/self/fd/2 ]
set -g __fisher_stderr /proc/self/fd/2
else
echo "No suitable stderr"
return 1
end
function __fisher_show_spinner
if not set -q __fisher_fg_spinner[1]
set -g __fisher_fg_spinner $fisher_spinners
end
printf " $__fisher_fg_spinner[1]\r" >&2
set -e __fisher_fg_spinner[1]
end
set -l config_home $XDG_CONFIG_HOME
set -l cache_home $XDG_CACHE_HOME
if test -z "$config_home"
set config_home ~/.config
end
if test -z "$cache_home"
set cache_home ~/.cache
end
if test -z "$fish_config"
set -g fish_config "$config_home/fish"
end
if test -z "$fisher_config"
set -g fisher_config "$config_home/fisherman"
end
if test -z "$fisher_cache"
set -g fisher_cache "$cache_home/fisherman"
end
if test -z "$fish_path"
set -g fish_path "$fish_config"
end
if test -z "$fisher_file"
set -g fisher_file "$fish_path/fishfile"
end
if test -z "$fisher_copy"
set -g fisher_copy false
end
switch "$argv[1]"
case --complete
__fisher_complete
return
case -v --version
__fisher_version
return
case -h
__fisher_usage >&2
return
end
command mkdir -p {"$fish_path","$fish_config"}/{conf.d,functions,completions} "$fisher_config" "$fisher_cache"
or return 1
set -l completions "$fish_path/completions/$fisher_cmd_name.fish"
if test ! -e "$completions"
echo "$fisher_cmd_name --complete" > "$completions"
__fisher_complete
end
for i in -q --quiet
if set -l index (builtin contains --index -- $i $argv)
set -e argv[$index]
set __fisher_stdout /dev/null
set __fisher_stderr /dev/null
break
end
end
set -l cmd
switch "$argv[1]"
case i install
set -e argv[1]
if test -z "$argv"
set cmd "default"
else
set cmd "install"
end
case u up update
set -e argv[1]
set cmd "update"
case r rm remove uninstall
set -e argv[1]
set cmd "rm"
case l ls list
set -e argv[1]
set cmd "ls"
case info ls-remote
set -e argv[1]
set cmd "ls-remote"
case h help
set -e argv[1]
__fisher_help $argv
return
case --help
set -e argv[1]
__fisher_help
return
case -- ""
set -e argv[1]
if test -z "$argv"
set cmd "default"
else
set cmd "install"
end
case self-{uninstall,destroy}
set -e argv[1]
__fisher_self_uninstall $argv
return
case -\*\?
printf "$fisher_cmd_name: '%s' is not a valid option\n" "$argv[1]" >&2
__fisher_usage >&2
return 1
case \*
set cmd "install"
end
set -l elapsed (__fisher_get_epoch_in_ms)
set -l items (
if test ! -z "$argv"
printf "%s\n" $argv | __fisher_read_bundle_file
end
)
if test -z "$items" -a "$cmd" = "default"
if isatty
command touch "$fisher_file"
set cmd "install"
set items (__fisher_read_bundle_file < "$fisher_file")
if test -z "$items"
__fisher_log info "
No plugins to install or dependencies missing.
" >&2
__fisher_log info "
See &$fisher_cmd_name help& for usage instructions.
" >&2
return
end
else
set cmd "install"
end
end
switch "$cmd"
case install update
if not command -s git > /dev/null
__fisher_log error "
git is required to download plugin repositories.
" >&2
__fisher_log info "
Please install git and try again.
Visit <&https://git-scm.com&> for more information.
" >&2
return 1
end
case ls ls-remote
if not command -s curl > /dev/null
__fisher_log error "
curl is required to query the GitHub API.
" >&2
__fisher_log info "
Please install curl and try again.
Refer to your package manager documentation for instructions.
" >&2
return 1
end
end
switch "$cmd"
case install
if __fisher_install $items
__fisher_log info "Done in &"(__fisher_get_epoch_in_ms $elapsed | __fisher_humanize_duration)"&" "$__fisher_stderr"
end
case update
if isatty
if test -z "$items"
set items (__fisher_list | command sed 's/^[@* ]*//')
if not __fisher_self_update
if test -z "$items"
__fisher_log info "Use your package manager to update fisherman."
return 1
end
end
end
else
__fisher_parse_column_output | __fisher_read_bundle_file | read -laz _items
set items $items $_items
end
__fisher_update $items
__fisher_log info "Done in &"(__fisher_get_epoch_in_ms $elapsed | __fisher_humanize_duration)"&" "$__fisher_stderr"
case ls
if test (count "$argv") -ge 0 -o "$argv" = -
if isatty stdout
__fisher_list | column -c$argv
else
__fisher_list | sed 's|^[@* ]*||'
end
else
__fisher_list_plugin_directory $argv
end
case ls-remote
set -l format
if test ! -z "$argv"
switch "$argv[1]"
case --format\*
set format (printf "%s\n" "$argv[1]" | command sed 's|^--[^= ]*[= ]\(.*\)|\1|')
set -e argv[1]
end
if test -z "$format"
set format "%info\n%url\n"
end
end
if test -z "$format"
set format "%name\n"
if isatty stdout
__fisher_list_remote "$format" $argv | column
else
__fisher_list_remote "$format" $argv
end
else
__fisher_list_remote "$format" $argv
end
case rm
if test -z "$items"
__fisher_parse_column_output | __fisher_read_bundle_file | read -az items
end
for i in $items
set -l name (__fisher_plugin_get_names $i)[1]
if test ! -d "$fisher_config/$name"
set -e items
if test -L "$fisher_config/$name"
set -l real_path (command readlink "$fisher_config/$name")
__fisher_log error "
I can't remove &$name& without its real path.
" "$__fisher_stderr"
__fisher_log info "
Restore &$real_path& and try again.
" "$__fisher_stderr"
else
__fisher_log error "Plugin &$name& is not installed." "$__fisher_stderr"
end
break
end
end
if test ! -z "$items"
__fisher_remove $items
__fisher_log info "Done in &"(
__fisher_get_epoch_in_ms $elapsed | __fisher_humanize_duration)"&" "$__fisher_stderr"
end
end
set -l config_glob $fisher_config/*
set -l config (
if test ! -z "$config_glob"
command find $config_glob -maxdepth 0 -type d | command sed "s|.*/||"
end
)
switch "$cmd"
case ls ls-remote
case \*
if test -z "$config"
echo > "$fisher_file"
set -e fisher_dependency_count
else
__fisher_plugin_get_url_info -- "$fisher_config"/$config > $fisher_file
end
end
complete -c $fisher_cmd_name --erase
__fisher_complete
end
function __fisher_install
if test -z "$argv"
__fisher_read_bundle_file | read -az argv
end
set -e __fisher_fetch_plugins_state
if set -l fetched (__fisher_plugin_fetch_items (__fisher_plugin_get_missing $argv))
if test -z "$fetched"
__fisher_log info "
No plugins to install or dependencies missing.
" "$__fisher_stderr"
return 1
end
for i in $fetched
__fisher_show_spinner
if test -f "$fisher_config/$i/fishfile"
while read -l i
set -l name (__fisher_plugin_get_names "$i")[1]
if contains -- "$name" $fetched
if contains -- "$name" $argv
__fisher_plugin_increment_ref_count "$name"
end
else
__fisher_plugin_increment_ref_count "$name"
end
end < "$fisher_config/$i/fishfile"
end
__fisher_show_spinner
__fisher_plugin_increment_ref_count "$i"
set -l path "$fisher_config/$i"
if __fisher_plugin_is_prompt "$path"
if test ! -z "$fisher_active_prompt"
__fisher_remove "$fisher_active_prompt"
end
set -U fisher_active_prompt "$i"
end
__fisher_plugin_enable "$path"
end
else
__fisher_log error "
There was an error installing &$fetched& or more plugin/s.
" "$__fisher_stderr"
__fisher_log info "
Try using a namespace before the plugin name: &owner&/$fetched
" "$__fisher_stderr"
return 1
end
end
function __fisher_plugin_fetch_items
__fisher_show_spinner
set -l jobs
set -l links
set -l white
set -l count (count $argv)
if test "$count" -eq 0
return
end
switch "$__fisher_fetch_plugins_state"
case ""
if test "$count" = 1 -a -d "$argv[1]"
if test "$argv[1]" = "$PWD"
set -l home ~
set -l name (printf "%s\n" "$argv[1]" | command sed "s|$home|~|")
__fisher_log info "Installing &$name& " "$__fisher_stderr"
else
set -l name (printf "%s\n" "$argv[1]" | command sed "s|$PWD/||")
__fisher_log info "Installing &$name& " "$__fisher_stderr"
end
else
__fisher_log info "Installing &$count& plugin/s" "$__fisher_stderr"
end
set -g __fisher_fetch_plugins_state "fetching"
case "fetching"
if test "$count" -eq 1
__fisher_log info "Installing &1& dependency" "$__fisher_stderr"
else
__fisher_log info "Installing &$count& dependencies" "$__fisher_stderr"
end
set -g __fisher_fetch_plugins_state "done"
case "done"
end
for i in $argv
set -l names
set -l branch
switch "$i"
case \*gist.github.com\*
__fisher_log okay "Resolving gist name."
if not set names (__fisher_get_plugin_name_from_gist "$i") ""
__fisher_log error "
I couldn't clone this gist:
&$i&
"
continue
end
case \*
printf "%s\n" "$i" | sed 's/[@:]\(.*\)/ \1/' | read i branch
set names (__fisher_plugin_get_names "$i")
end
if test -d "$i"
command ln -sf "$i" "$fisher_config/$names[1]"
set links $links "$names[1]"
continue
end
set -l src "$fisher_cache/$names[1]"
if test -z "$names[2]"
if test -d "$src" -a -z "$branch"
if test ! -d "$fisher_config/$names[1]"
__fisher_log okay "Copy &$names[1]&" "$__fisher_stderr"
end
if test -L "$src"
command ln -sf "$src" "$fisher_config"
else
command cp -Rf "$src" "$fisher_config"
end
else
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]" "$branch")
end
else
if test -d "$src" -a -z "$branch"
set -l real_namespace (__fisher_plugin_get_url_info --dirname "$src")
if test "$real_namespace" = "$names[2]"
if test ! -d "$fisher_config/$names[1]"
__fisher_log okay "Copy &$names[1]&" "$__fisher_stderr"
end
command cp -Rf "$src" "$fisher_config"
else
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]" "$branch")
end
else
set jobs $jobs (__fisher_plugin_url_clone_async "$i" "$names[1]" "$branch")
end
end
set fetched $fetched "$names[1]"
end
__fisher_jobs_await $jobs
for i in $fetched
if test ! -d "$fisher_cache/$i"
printf "%s\n" "$i"
for i in $fetched
if test -d "$fisher_config/$i"
command rm -rf "$fisher_config/$i"
end
end
return 1
end
end
if test ! -z "$fetched"
__fisher_plugin_fetch_items (__fisher_plugin_get_missing $fetched)
printf "%s\n" $fetched
end
if test ! -z "$links"
__fisher_plugin_fetch_items (__fisher_plugin_get_missing $links)
printf "%s\n" $links
end
end
function __fisher_plugin_url_clone_async -a url name branch
switch "$url"
case http://\* https://\*
case {gitlab.com,github.com,bitbucket.org}\*
set url "https://$url"
case \?\*/\?\*
set url "https://github.com/$url"
case \*
set url "https://github.com/fisherman/$url"
end
set -l nc (set_color normal)
set -l error (set_color $fish_color_error)
set -l okay (set_color $fish_color_match)
set -l hm_url (printf "%s\n" "$url" | command sed 's|^https://||')
if test ! -z "$branch"
set hm_url "$hm_url ($branch)"
set branch -b "$branch"
end
fish -c "
set -lx GIT_ASKPASS /bin/echo
if test -d '$fisher_cache/$name'
command rm -rf '$fisher_cache/$name'
end
if command git clone $branch -q --depth 1 '$url' '$fisher_cache/$name' 2> /dev/null
printf '$okay""OK""$nc Fetch $okay%s$nc %s\n' '$name' '$hm_url' > $__fisher_stderr
command cp -Rf '$fisher_cache/$name' '$fisher_config'
else
printf '$error""!""$nc Fetch $error%s$nc %s\n' '$name' '$hm_url' > $__fisher_stderr
end
" >&2
__fisher_jobs_get -l
end
function __fisher_update
set -l jobs
set -l count (count $argv)
set -l updated
set -l links 0
if test "$count" = 0
return
end
if test "$count" -eq 1
__fisher_log info "Updating &$count& plugin" "$__fisher_stderr"
else
__fisher_log info "Updating &$count& plugins" "$__fisher_stderr"
end
for i in $argv
set -l name (__fisher_plugin_get_names "$i")[1]
set -l path "$fisher_config/$name"
if test -d "$path"
set updated $updated "$name"
if test -L "$fisher_config/$name"
set links (math "$links + 1")
continue
end
set jobs $jobs (__fisher_update_path_async "$name" "$path")
else
__fisher_log error "Skipped &$name&"
end
end
__fisher_jobs_await $jobs
set -g __fisher_fetch_plugins_state "fetching"
set -l fetched (__fisher_plugin_fetch_items (__fisher_plugin_get_missing $updated))
for i in $updated $fetched
__fisher_plugin_enable "$fisher_config/$i"
end
if test "$links" -gt 0
__fisher_log info "Synced &$links& symlink/s" "$__fisher_stderr"
end
end
function __fisher_self_update
set -l file (status --current-filename)
if test "$file" != "$fish_path/functions/$fisher_cmd_name.fish"
return 1
end
set -l completions "$fish_path/completions/$fisher_cmd_name.fish"
set -l raw_url "https://raw.githubusercontent.com/fisherman/fisherman/master/fisher.fish"
set -l fake_qs (date "+%s")
set -l previous_version "$fisher_version"
fish -c "curl --max-time 5 -sS '$raw_url?$fake_qs' > $file.$fake_qs" &
__fisher_jobs_await (__fisher_jobs_get -l)
if test -s "$file.$fake_qs"
command mv "$file.$fake_qs" "$file"
end
builtin source "$file" 2> /dev/null
echo "$fisher_cmd_name -v" | source > /dev/null
set -l new_version "$fisher_version"
echo "$fisher_cmd_name --complete" > "$completions"
builtin source "$completions" 2> /dev/null
if test "$previous_version" = "$fisher_version"
__fisher_log okay "fisherman is up to date" "$__fisher_stderr"
else
__fisher_log okay "You are running fisherman &$fisher_version&" "$__fisher_stderr"
__fisher_log info "See github.com/fisherman/fisherman/releases" "$__fisher_stderr"
end
end
function __fisher_update_path_async -a name path
set -l nc (set_color normal)
set -l error (set_color $fish_color_match)
set -l okay (set_color $fish_color_match)
fish -c "
pushd $path
set -l branch (basename (command git symbolic-ref HEAD 2> /dev/null))
set -l hm_branch
if test -z \"\$branch\"
set branch master
end
if test \"\$branch\" != master
set hm_branch \" (\$branch)\"
end
if not command git fetch -q origin \$branch 2> /dev/null
printf '$error""!""$nc Fetch $error%s$nc\n' '$name' > $__fisher_stderr
exit
end
set -l commits (command git rev-list --left-right --count \$branch..FETCH_HEAD 2> /dev/null | cut -d\t -f2)
command git reset -q --hard FETCH_HEAD 2> /dev/null
command git clean -qdfx
command cp -Rf '$path/.' '$fisher_cache/$name'
if test -z \"\$commits\" -o \"\$commits\" -eq 0
printf '$okay""OK""$nc Latest $okay%s$nc%s\n' '$name' \$hm_branch > $__fisher_stderr
else
printf '$okay""OK""$nc Pulled $okay%s$nc new commit/s $okay%s$nc%s\n' \$commits '$name' \$hm_branch > $__fisher_stderr
end
" >&2 &
__fisher_jobs_get -l
end
function __fisher_plugin_enable -a path
set -l plugin_name (basename $path)
for file in $path/{functions/*,}*.fish
set -l base (basename "$file")
if test "$base" = "uninstall.fish"
continue
end
switch "$base"
case {,fish_{,user_}}key_bindings.fish
__fisher_key_bindings_remove "$plugin_name"
__fisher_key_bindings_append "$plugin_name" "$file"
continue
end
set -l dir "functions"
if test "$base" = "init.fish"
set dir "conf.d"
set base "$plugin_name.$base"
end
set -l target "$fish_path/$dir/$base"
if test -e "$target" -a ! -L "$target"
set -l backup_target "$fish_path/$dir/copy-$base"
__fisher_log info "Backup &$base&" "$__fisher_stderr"
command mv -f "$target" "$backup_target" 2> /dev/null
end
if test $fisher_copy = true
command cp -Rf "$file" "$target"
else
command ln -sf "$file" "$target"
end
builtin source "$target" 2> /dev/null
if test "$base" = "set_color_custom.fish"
if test ! -s "$fish_path/fish_colors"
__fisher_print_fish_colors > "$fish_path/fish_colors"
end
set_color_custom
end
end
for file in $path/{functions/,}*.{py,awk}
set -l base (basename "$file")
if test $fisher_copy = true
command cp -Rf "$file" "$fish_path/functions/$base"
else
command ln -sf "$file" "$fish_path/functions/$base"
end
end
for file in $path/conf.d/*.{py,awk}
set -l base (basename "$file")
if test $fisher_copy = true
command cp -Rf "$file" "$fish_path/conf.d/$base"
else
command ln -sf "$file" "$fish_path/conf.d/$base"
end
end
for file in $path/conf.d/*.fish
set -l base (basename "$file")
set -l target "$fish_path/conf.d/$base"
if test $fisher_copy = true
command cp -Rf "$file" "$target"
else
command ln -sf "$file" "$target"
end
builtin source "$target" 2> /dev/null
end
for file in $path/completions/*.fish
set -l base (basename "$file")
set -l target "$fish_path/completions/$base"
if test $fisher_copy = true
command cp -Rf "$file" "$target"
else
command ln -sf "$file" "$target"
end
builtin source "$target" 2> /dev/null
end
return 0
end
function __fisher_plugin_disable -a path
set -l plugin_name (basename $path)
for i in "$path/functions/uninstall.fish" "$path/uninstall.fish"
if test -s "$i"
builtin source "$i" 2> /dev/null
break
end
end
for file in $path/{functions/*,}*.fish
set -l name (basename "$file" .fish)
set -l base "$name.fish"
if test "$base" = "uninstall.fish"
continue
end
switch "$base"
case {,fish_}key_bindings.fish
__fisher_key_bindings_remove "$plugin_name"
continue
end
set -l dir "functions"
if test "$base" = "init.fish"
set dir "conf.d"
set base "$plugin_name.$base"
end
set -l target "$fish_path/$dir/$base"
command rm -f "$target"
functions -e "$name"
set -l backup_source "$fish_path/$dir/copy-$base"
if test -e "$backup_source"
command mv "$backup_source" "$target"
builtin source "$target" 2> /dev/null
end
if test "$base" = "set_color_custom.fish"
set -l fish_colors_config "$fish_path/fish_colors"
if test ! -f "$fish_colors_config"
__fisher_reset_default_fish_colors
continue
end
__fisher_restore_fish_colors < $fish_colors_config | builtin source 2> /dev/null
command rm -f $fish_colors_config
end
end
for file in $path/conf.d/*.{py,awk}
set -l base (basename "$file")
command rm -f "$fish_path/conf.d/$base"
end
for file in $path/{functions/,}*.{py,awk}
set -l base (basename "$file")
command rm -f "$fish_path/functions/$base"
end
for file in $path/conf.d/*.fish
set -l base (basename "$file")
command rm -f "$fish_path/conf.d/$base"
end
for file in $path/completions/*.fish
set -l name (basename "$file" .fish)
set -l base "$name.fish"
command rm -f "$fish_path/completions/$base"
complete -c "$name" --erase
end
if __fisher_plugin_is_prompt "$path"
set -U fisher_active_prompt
builtin source $__fish_datadir/functions/fish_prompt.fish 2> /dev/null
end
command rm -rf "$path" >&2
end
function __fisher_remove
if test -z "$argv"
return 1
end
set -l orphans
set -l removed
for i in $argv
set -l name (__fisher_plugin_get_names "$i")[1]
if test ! -d "$fisher_config/$name"
continue
end
set removed $removed $name
__fisher_show_spinner
__fisher_plugin_decrement_ref_count "$name"
if test -s "$fisher_config/$name/fishfile"
while read -l i
set -l name (__fisher_plugin_get_names "$i")[1]
if test (__fisher_plugin_get_ref_count "$name") -le 1
set orphans $orphans "$name"
else
__fisher_plugin_decrement_ref_count "$name"
end
__fisher_show_spinner
end < "$fisher_config/$name/fishfile"
end
__fisher_plugin_disable "$fisher_config/$name"
__fisher_show_spinner
end
for i in $orphans
__fisher_remove "$i" >&2