aboutsummaryrefslogtreecommitdiffstats
path: root/fish/functions/fisher.fish
blob: 5dae6cc423d1ba8e5f87f30f07cc62f4e086165d (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
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
    end
end


function __fisher_get_plugin_name_from_gist -a url
    set -l gist_id (printf "%s\n" "$url" | command sed 's|.*/||')
    set -l name (fish -c "

        $fisher_cmd_name -v > /dev/null
        curl -Ss https://api.github.com/gists/$gist_id &

        __fisher_jobs_await (__fisher_jobs_get -l)

    " | command awk '

        /"files": / {
            files++
        }

        /"[^ ]+.fish": / && files {
            gsub("^ *\"|\.fish.*", "")
            print
        }

    ')

    if test -z "$name"
        return 1
    end

    printf "%s\n" $name
end


function __fisher_remote_parse_header
    command awk '

        function get_page_count(s, rstart, rlength,    pages) {
            if (split(substr(s, rstart, rlength), pages, "=")) {
                return pages[2]
            }
        }

        BEGIN {
            FS = " <|>; |, <"
        }

        /^Link: / {
            if (match($2, "&page=[0-9]*")) {
                url = substr($2, 1, RSTART - 1)
                page_next = get_page_count($2, RSTART, RLENGTH)

                if (page_next) {
                    page_last = get_page_count($4, RSTART, RLENGTH)

                    printf("%s\n%s\n%s", url, page_next, page_last)
                }
            }
        }

    '
end


function __fisher_remote_index_update
    set -l index "$fisher_cache/.index"
    set -l interval 3240
    set -l players "fisherman" "oh-my-fish"

    if test ! -z "$fisher_index_update_interval"
        set interval "$fisher_index_update_interval"
    end

    if test -s "$index"
        if set -l file_age (__fisher_get_file_age "$index")
            if test "$file_age" -lt "$interval"
                return
            end
        end
    end

    for i in $players
        curl -u$GITHUB_USER:$GITHUB_TOKEN -Is "https://api.github.com/orgs/$i/repos?per_page=100" > "$index-header-$i" &
    end

    __fisher_jobs_await (__fisher_jobs_get -l)

    for i in $players
        set -l url "https://api.github.com/orgs/$i/repos?per_page=100"
        set -l next 0
        set -l last 0
        set -l data

        if test -s "$index-header-$i"
            __fisher_remote_parse_header < "$index-header-$i" | read -az data
            command rm -f "$index-header-$i"
        end

        if set -q data[3]
            set -l url "$data[1]"
            set -l next "$data[2]"
            set -l last "$data[3]"
        end

        for page in "" (seq "$next" "$last")
            if test "$page" = 0
                continue
            end

            set -l next_url "$url"

            if test ! -z "$page"
                set next_url "$url&page=$page"
            end

            curl -u$GITHUB_USER:$GITHUB_TOKEN --max-time 10 -s "$next_url" | command awk -v ORS='' '

                {
                    gsub(/[{}[]]/, "")

                } //

            ' | command awk '

                {
                    n = split($0, a, /,[\t ]*"/)

                    for (i = 1; i <= n; i++) {
                        gsub(/"/, "", a[i])
                        print(a[i])
                    }
                }

            ' > "$index-$i-$page" &
        end
    end

    __fisher_jobs_await (__fisher_jobs_get -l)

    for i in $players
        command cat "$index-$i-"*
    end > "$index"

    command rm "$index"-*

    if test ! -s "$index"
        return 1
    end

    command awk '

        function quicksort(list, lo, hi, pivot,   j, i, t) {
            pivot = j = i = t

            if (lo >= hi) {
                return
            }

            pivot = lo
            i = lo
            j = hi

            while (i < j) {
                while (list[i] <= list[pivot] && i < hi) {
                    i++
                }

                while (list[j] > list[pivot]) {
                    j--
                }

                if (i < j) {
                    t = list[i]
                    list[i] = list[j]
                    list[j] = t
                }
            }

            t = list[pivot]

            list[pivot] = list[j]
            list[j] = t

            quicksort(list, lo, j - 1)
            quicksort(list, j + 1, hi)
        }

        function reset_vars() {
            name = info = stars = url = ""
        }

        {
            if (match($0, /^name:[[:blank:]]*/)) {
                name = substr($0, RLENGTH+1)
            }

            if (match($0, /^description:[[:blank:]]*/)) {
                info = substr($0, RLENGTH+1)
            }

            if (match($0, /^stargazers_count:[[:blank:]]*/)) {
                stars = substr($0, RLENGTH+1)
            }

            if (name != "" && stars != "") {
                if (name ~ /oh-my-fish/) {
                    reset_vars()
                    next
                }

                url = "github.com/fisherman/" name

                if (name ~ /^(plugin|theme)-/) {
                    gsub(/^plugin-/, "", name)

                    if (seen_names[name]) {
                        reset_vars()
                        next
                    }

                    url = "github.com/oh-my-fish/" name
                    name = "omf/" name

                } else {
                    seen_names[name]++
                }

                if (info == "" || info == "null") {
                    info = url
                }

                if (info ~ /\.$/) {
                    info = substr(info, 1, length(info) - 1)
                }

                records[++record_count] = name "\t" info "\t" url "\t" stars
                reset_vars()
            }
        }

        END {
            quicksort(records, 1, record_count)

            for (i = 1; i <= record_count; i++) {
                print(records[i])
            }
        }

    ' < "$index" > "$index-tab"

    if test ! -s "$index-tab"
        command rm "$index"
        return 1
    end

    command mv -f "$index-tab" "$index"
end


function __fisher_list_remote -a format
    set -l index "$fisher_cache/.index"

    if not __fisher_remote_index_update
        __fisher_log error "I could not update the remote index."
        __fisher_log info "

            This is most likely a problem with http://api.github.com/
            or a connection timeout. If the problem persists, open an
            issue in: <github.com/fisherman/fisherman/issues>
        "

        return 1
    end

    set -e argv[1]
    set -l keys $argv

    command awk -v FS=\t -v format_s="$format" -v keys="$keys" '

        function basename(s,   n, a) {
            n = split(s, a, "/")
            return a[n]
        }

        function record_printf(fmt, name, info, url, stars) {
            gsub(/%name/, name, fmt)
            gsub(/%stars/, stars, fmt)
            gsub(/%url/, url, fmt)
            gsub(/%info/, info, fmt)

            printf("%s", fmt)
        }

        BEGIN {
            keys_n = split(keys, keys_a, " ")
        }

        {
            if (keys_n > 0) {
                for (i = 1; i <= keys_n; i++) {
                    if (keys_a[i] == $1) {
                        record_printf(format_s, $1, $2, $3, $4)
                        next
                    }
                }
            } else if ($1 !~ /^fisherman/) {
                record_printf(format_s, $1, $2, $3, $4)
            }
        }

    ' < "$index"
end


function __fisher_list
    set -l config "$fisher_config"/*

    if test -z "$config"
        return 1
    end

    set -l white
    set -l links (command find $config -maxdepth 0 -type l ! -name "$fisher_active_prompt" 2> /dev/null)
    set -l names (command find $config -maxdepth 0 -type d ! -name "$fisher_active_prompt" 2> /dev/null)

    if test ! -z "$links"
        set white "  "
        printf "%s\n" $links | command sed "s|.*/|@ |"
    end

    if test ! -z "$fisher_active_prompt"
        set white "  "
        printf "* %s\n" "$fisher_active_prompt"
    end

    if test ! -z "$names"
        printf "%s\n" $names | command sed "s|.*/|$white|"
    end
end


function __fisher_list_plugin_directory
    if test -z "$argv"
        return 1
    end

    for i in $argv
        if test ! -d "$fisher_config/$i"
            __fisher_log error "You can only list plugins you've installed." "$__fisher_stderr"

            return 1
        end
    end

    set -l fd "$__fisher_stderr"
    set -l uniq_items

    for i in $argv
        if contains -- "$i" $uniq_items
            continue
        end

        set uniq_items $uniq_items "$i"
        set -l path "$fisher_config/$i"

        pushd "$path"

        set -l color (set_color $fish_color_command)
        set -l nc (set_color normal)
        set -l previous_tree

        if contains -- --no-color $argv
            set color
            set nc
            set fd "$__fisher_stdout"
        end

        printf "$color%s$nc\n" "$PWD" > $fd

        for file in .* **
            if test -f "$file"
                switch "$file"
                    case \*/\*
                        set -l current_tree (dirname $file)

                        if test "$previous_tree" != "$current_tree"
                            printf "    $color%s/$nc\n" $current_tree
                        end

                        printf "        %s\n" (basename $file)

                        set previous_tree $current_tree

                    case \*
                        printf "    %s\n" $file
                end
            end
        end > $fd

        popd
    end
end


function __fisher_log -a log message fd
    if test -z "$argv"
        return
    end

    switch "$fd"
        case "/dev/null"
            return

        case "" "/dev/stderr"
            set fd $__fisher_stderr

        case \*
            set nc ""
            set okay ""
            set info ""
            set error ""
    end

    set -l nc (set_color normal)
    set -l okay (set_color $fish_color_match)
    set -l info (set_color $fish_color_match)
    set -l error (set_color $fish_color_error)

    printf "%s\n" "$message" | command awk '
        function okay(s) {
            printf("'"$okay"'%s'"$nc"' %s\n", "OK", s)
        }

        function info(s) {
            printf("%s\n", s)
        }

        function error(s) {
            printf("'"$error"'%s'"$nc"' %s\n", "!", s)
        }

        {
            sub(/^[ ]+/, "")
            gsub("``", "  ")

            if (/&[^&]+&/) {
                n = match($0, /&[^&]+&/)
                if (n) {
                    sub(/&[^&]+&/, "'"$$log"'" substr($0, RSTART + 1, RLENGTH - 2) "'"$nc"'", $0)
                }
            }

            s[++len] = $0
        }

        END {
            for (i = 1; i <= len; i++) {
                if ((i == 1 || i == len) && (s[i] == "")) {
                    continue
                }

                if (s[i] == "") {
                    print
                } else {
                    '"$log"'(s[i])
                }
            }
        }

    ' > "$fd"
end


function __fisher_jobs_get
    jobs $argv | command awk -v FS=\t '
        /[0-9]+\t/{
            jobs[++job_count] = $1
        }

        END {
            for (i = 1; i <= job_count; i++) {
                print(jobs[i])
            }

            exit job_count == 0
        }
    '
end


function __fisher_jobs_await
    if test -z "$argv"
        return
    end

    while true
        for spinner in $fisher_spinners
            printf "  $spinner  \r" >&2
            sleep 0.05
        end

        set -l currently_active_jobs (__fisher_jobs_get)

        if test -z "$currently_active_jobs"
            break
        end

        set -l has_jobs

        for i in $argv
            if builtin contains -- $i $currently_active_jobs
                set has_jobs "*"
                break
            end
        end

        if test -z "$has_jobs"
            break
        end
    end
end


function __fisher_key_bindings_remove -a plugin_name
    set -l user_key_bindings "$fish_path/functions/fish_user_key_bindings.fish"

    if test ! -f "$user_key_bindings"
        return
    end

    set -l tmp (date "+%s")

    fish_indent < "$user_key_bindings" | command sed -n "/### $plugin_name ###/,/### $plugin_name ###/{s/^ *bind /bind -e /p;};" | builtin source 2> /dev/null

    command sed "/### $plugin_name ###/,/### $plugin_name ###/d" < "$user_key_bindings" > "$user_key_bindings.$tmp"
    command mv -f "$user_key_bindings.$tmp" "$user_key_bindings"

    if command awk '
        /^$/ { next }

        /^function fish_user_key_bindings/ {
            i++
            next
        }

        /^end$/ && 1 == i {
            exit 0
        }

        // {
            exit 1
        }

    ' < "$user_key_bindings"

        command rm -f "$user_key_bindings"
    end
end


function __fisher_key_bindings_append -a plugin_name file
    set -l user_key_bindings "$fish_path/functions/fish_user_key_bindings.fish"

    command mkdir -p (dirname "$user_key_bindings")
    command touch "$user_key_bindings"

    set -l key_bindings_source (
        fish_indent < "$user_key_bindings" | command awk '

            /^function fish_user_key_bindings/ {
                reading_function_source = 1
                next
            }

            /^end$/ && reading_function_source {
                exit
            }

            reading_function_source {
                print($0)
                next
            }

        '
    )

    set -l plugin_key_bindings_source (
        fish_indent < "$file" | command awk -v name="$plugin_name" '

            BEGIN {
                printf("### %s ###\n", name)
            }

            END {
                printf("### %s ###\n", name)
            }

            /^function (fish_(user_)?)?key_bindings$/ {
                is_end = 1
                next
            }

            /^end$/ && is_end {
                end = 0
                next
            }

            !/^ *(#.*)*$/ {
                gsub("#.*", "")
                printf("%s\n", $0)
            }

        '
    )

    printf "%s\n" $plugin_key_bindings_source | source 2> /dev/null

    fish_indent < "$user_key_bindings" | command awk '
        {

            if ($0 ~ /^function fish_user_key_bindings/) {
                reading_function_source = 1
                next
            } else if ($0 ~ /^end$/ && reading_function_source) {
                reading_function_source = 0
                next
            }

            if (!reading_function_source) {
                print($0)
            }
        }

    ' > "$user_key_bindings-copy"

    command mv -f "$user_key_bindings-copy" "$user_key_bindings"

    printf "%s\n" $key_bindings_source $plugin_key_bindings_source | command awk '

        BEGIN {
            print "function fish_user_key_bindings"
        }

        //

        END {
            print "end"
        }

    ' | fish_indent >> "$user_key_bindings"
end


function __fisher_plugin_is_prompt -a path
    for file in "$path"/{,functions/}{fish_prompt,fish_right_prompt}.fish
        if test -e "$file"
            return
        end
    end

    return 1
end


function __fisher_plugin_get_names
    printf "%s\n" $argv | command awk '

        {
            sub(/\/$/, "")
            n = split($0, s, "/")
            sub(/^(omf|omf-theme|omf-plugin|plugin|theme|fish|fisher|fish-plugin|fish-theme)-/, "", s[n])

            printf("%s\n%s\n", s[n], s[n - 1])
        }

    '
end


function __fisher_plugin_get_url_info -a option
    set -e argv[1]

    if test -z "$argv"
        return
    end

    for dir in $argv
        git -C $dir config remote.origin.url 2> /dev/null | command awk -v option="$option" '
            {
                n = split($0, s, "/")

                if ($0 ~ /https:\/\/gist/) {
                    printf("# %s\n", $0)
                    next
                }

                if (option == "--dirname") {
                    printf("%s\n", s[n - 1])

                } else if (option == "--basename") {
                    printf("%s\n", s[n])

                } else {
                    printf("%s/%s\n", s[n - 1], s[n])
                }
            }
        '
    end
end


function __fisher_plugin_normalize_path
    printf "%s\n" $argv | command awk -v pwd="$PWD" '

        /^\.$/ {
            print(pwd)
            next
        }

        /^\// {
            sub(/\/$/, "")
            print($0)
            next
        }

        {
            print(pwd "/" $0)
            next
        }

    '
end


function __fisher_plugin_get_missing
    for i in $argv
        if test -d "$i"
            set i (__fisher_plugin_normalize_path "$i")
        end

        set -l name (__fisher_plugin_get_names "$i")[1]

        if test "$name" = fisherman

            __fisher_log info "
                Run &$fisher_cmd_name update& to update fisherman.
            " >&2
            continue
        end

        if set -l path (__fisher_plugin_is_installed "$name")
            for file in fishfile bundle
                if test -s "$path/$file"
                    __fisher_plugin_get_missing (__fisher_read_bundle_file < "$path/$file")
                end
            end
        else
            printf "%s\n" "$i"
        end
    end

    __fisher_show_spinner
end


function __fisher_plugin_is_installed -a name
    if test -z "$name" -o ! -d "$fisher_config/$name"
        return 1
    end

    printf "%s\n" "$fisher_config/$name"
end


function __fisher_print_fish_colors
    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"
end


function __fisher_restore_fish_colors
    command awk '
        {
            if ($0 == "") {
                set_option "-e"
            } else {
                set_option "-U"
            }
        }

        NR == 1 {
            print("set " set_option " fish_color_normal " $0)
        }
        NR == 2 {
            print("set " set_option " fish_color_command " $0)
        }
        NR == 3 {
            print("set " set_option " fish_color_param " $0)
        }
        NR == 4 {
            print("set " set_option " fish_color_redirection " $0)
        }
        NR == 5 {
            print("set " set_option " fish_color_comment " $0)
        }
        NR == 6 {
            print("set " set_option " fish_color_error " $0)
        }
        NR == 7 {
            print("set " set_option " fish_color_escape " $0)
        }
        NR == 8 {
            print("set " set_option " fish_color_operator " $0)
        }
        NR == 9 {
            print("set " set_option " fish_color_end " $0)
        }
        NR == 10 {
            print("set " set_option " fish_color_quote " $0)
        }
        NR == 11 {
            print("set " set_option " fish_color_autosuggestion " $0)
        }
        NR == 12 {
            print("set " set_option " fish_color_user " $0)
        }
        NR == 13 {
            print("set " set_option " fish_color_valid_path " $0)
        }
        NR == 14 {
            print("set " set_option " fish_color_cwd " $0)
        }
        NR == 15 {
            print("set " set_option " fish_color_cwd_root " $0)
        }
        NR == 16 {
            print("set " set_option " fish_color_match " $0)
        }
        NR == 17 {
            print("set " set_option " fish_color_search_match " $0)
        }
        NR == 18 {
            print("set " set_option " fish_color_selection " $0)
        }
        NR == 19 {
            print("set " set_option " fish_pager_color_prefix " $0)
        }
        NR == 20 {
            print("set " set_option " fish_pager_color_completion " $0)
        }
        NR == 21 {
            print("set " set_option " fish_pager_color_description " $0)
        }
        NR == 22 {
            print("set " set_option " fish_pager_color_progress " $0)
        }
        NR == 23 {
            print("set " set_option " fish_color_history_current " $0)
        }
        NR == 24 {
            print("set " set_option " fish_color_host " $0)
        }

    '
end


function __fisher_reset_default_fish_colors
    set -U fish_color_normal normal
    set -U fish_color_command 005fd7 purple
    set -U fish_color_param 00afff cyan
    set -U fish_color_redirection 005fd7
    set -U fish_color_comment 600
    set -U fish_color_error red --bold
    set -U fish_color_escape cyan
    set -U fish_color_operator cyan
    set -U fish_color_end green
    set -U fish_color_quote brown
    set -U fish_color_autosuggestion 555 yellow
    set -U fish_color_user green
    set -U fish_color_valid_path --underline
    set -U fish_color_cwd green
    set -U fish_color_cwd_root red
    set -U fish_color_match cyan
    set -U fish_color_search_match --background=purple
    set -U fish_color_selection --background=purple
    set -U fish_pager_color_prefix cyan
    set -U fish_pager_color_completion normal
    set -U fish_pager_color_description 555 yellow
    set -U fish_pager_color_progress cyan
    set -U fish_color_history_current cyan
    set -U fish_color_host normal
end


function __fisher_read_bundle_file
    command awk -v FS=\t '
        /^$/ || /^[ \t]*#/ || /^(--|-).*/ {
            next
        }

        /^omf\// {
            sub(/^omf\//, "oh-my-fish/")

            if ($0 !~ /(theme|plugin)-/) {
                sub(/^oh-my-fish\//, "oh-my-fish/plugin-")
            }
        }

        /^[ \t]*package / {
            sub("^[ \t]*package ", "oh-my-fish/plugin-")
        }

        {
            sub(/\.git$/, "")
            sub("^[@* \t]*", "")

            if (!dedupe[$0]++) {
                printf("%s\n", $0)
            }
        }
    '
end


function __fisher_plugin_increment_ref_count -a name
    set -U fisher_dependency_count $fisher_dependency_count $name
end


function __fisher_plugin_decrement_ref_count -a name
    if set -l i (contains --index -- "$name" $fisher_dependency_count)
        set -e fisher_dependency_count[$i]
    end
end


function __fisher_plugin_get_ref_count -a name
    printf "%s\n" $fisher_dependency_count | command awk -v plugin="$name" '

        BEGIN {
            i = 0
        }

        $0 == plugin {
            i++
        }

        END {
            print(i)
        }

    '
end


function __fisher_complete
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a install   -d "Install plugins"
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a update    -d "Update plugins and self"
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a rm        -d "Remove plugins"
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a ls        -d "List what you've installed"
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a ls-remote -d "List everything that's available"
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -a help      -d "Show help"

    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -s h -l help     -d "Show usage help"
    complete -xc $fisher_cmd_name -n "__fish_use_subcommand" -s v -l version  -d "Show version information"
    complete -xc $fisher_cmd_name -s q -l quiet -d "Enable quiet mode"

    complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from ls-remote" -l "format" -d "Format with verbs: %name, %url, %info and %stars"

    set -l config_glob "$fisher_config"/*
    set -l config (printf "%s\n" $config_glob | command sed "s|.*/||")

    if test ! -s "$fisher_cache/.index"
        if test ! -z "$config"
            complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$config"
            complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$fisher_active_prompt" -d "Prompt"
        end
        return
    end

    set -l real_home ~

    for name in (command find $config_glob -maxdepth 0 -type l 2> /dev/null)
        set -l path (command readlink "$name")
        set -l name (command basename "$name" | sed "s|$real_home|~|")

        complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$path"
    end

    set -l IFS \t

    command awk -v FS=\t -v OFS=\t '

        {
            print($1, $2)
        }

    ' "$fisher_cache/.index" 2> /dev/null | while read -l name info

        switch "$name"
            case fisherman\*
                continue
        end

        complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from info ls-remote" -a "$name" -d "$info"

        if contains -- "$name" $config
            complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$info"
        else
            complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from i in install" -a "$name" -d "$info"
        end
    end

    if functions -q __fisher_plugin_get_url_info
        for i in (__fisher_plugin_get_url_info -- $config_glob)
            switch "$i"
                case fisherman\*
                case \*
                    set -l name (__fisher_plugin_get_names "$i")[1]
                    complete -xc $fisher_cmd_name -n "__fish_seen_subcommand_from l ls list u up update r rm remove h help" -a "$name" -d "$i"
            end
        end
    end
end


function __fisher_humanize_duration
    command awk '
        function hmTime(time,   stamp) {
            split("h:m:s:ms", units, ":")

            for (i = 2; i >= -1; i--) {
                if (t = int( i < 0 ? time % 1000 : time / (60 ^ i * 1000) % 60 )) {
                    stamp = stamp t units[sqrt((i - 2) ^ 2) + 1] " "
                }
            }

            if (stamp ~ /^ *$/) {
                return "0ms"
            }

            return substr(stamp, 1, length(stamp) - 1)
        }

        {
            print hmTime($0)
        }
    '
end

function __fisher_get_key
    stty -icanon -echo 2> /dev/null
    printf "$argv" >&2
    while true
        dd bs=1 count=1 2> /dev/null | read -p "" -l yn
        switch "$yn"
            case y Y n N
                printf "\n" >&2
                printf "%s\n" $yn > /dev/stdout
                break
        end
    end
    stty icanon echo > /dev/stderr 2> /dev/null
end


switch (command uname)
    case Darwin FreeBSD
        function __fisher_get_epoch_in_ms -a elapsed
            if test -z "$elapsed"
                set elapsed 0
            end

            if command -s perl > /dev/null
                perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - '$elapsed')'
            else
                math (command date "+%s") - $elapsed
            end
        end

    case \*
        function __fisher_get_epoch_in_ms -a elapsed
            if test -z "$elapsed"
                set elapsed 0
            end
            math (command date "+%s%3N") - $elapsed
        end
end


function __fisher_parse_column_output
    command awk -v FS=\t '
        {
            for (i = 1; i <= NF; i++) {
                if ($i != "") {
                    print $i
                }
            }
        }
    '
end


function __fisher_get_file_age -a file
    if type -q perl
        perl -e "printf(\"%s\n\", time - (stat ('$file'))[9])" 2> /dev/null

    else if type -q python
        python -c "from __future__ import print_function; import os, time; print(int(time.time() - os.path.getmtime('$file')))" 2> /dev/null
    end
end


function __fisher_usage
    set -l u (set_color -u)
    set -l nc (set_color normal)

    echo "Usage: $fisher_cmd_name [COMMAND] [PLUGINS]"
    echo
    echo "where COMMAND is one of:"
    echo "      "$u"i"$nc"nstall (default)"
    echo "      "$u"u"$nc"pdate"
    echo "      "$u"r"$nc"m"
    echo "      "$u"l"$nc"s (or ls-remote [--format=FORMAT])"
    echo "      "$u"h"$nc"elp"
end


function __fisher_version
    set -l real_home ~
    printf "fisherman version $fisher_version %s\n" (
        __fisher_plugin_normalize_path (status -f) | command sed "s|$real_home|~|;s|$__fish_datadir|\$__fish_datadir|")
end

function __fisher_help -a cmd number
    if test -z "$argv"
        set -l page "$fisher_cache/$fisher_cmd_name.1"

        if test ! -s "$page"
            __fisher_man_page_write > "$page"
        end

        if [ "$PREFIX" = "/data/data/com.termux/files/usr" ]

          mandoc -a "$page"

        else

          set -l pager "/usr/bin/less -s"

          if test ! -z "$PAGER"
              set pager "$PAGER"
          end

          man -P "$pager" -- "$page"

        end

        command rm -f "$page"

    else
        if test -z "$number"
            set number 1
        end

        set -l page "$fisher_config/$cmd/man/man$number/$cmd.$number"

        if not man "$page" 2> /dev/null
            if test -d "$fisher_config/$cmd"
                __fisher_log info "There's no manual for this plugin." "$__fisher_stderr"

                set -l url (__fisher_plugin_get_url_info -- "$fisher_config/$cmd")

                __fisher_log info "Try online: <&github.com/$url&>" "$__fisher_stderr"
            else
                __fisher_log error "This plugin is not installed." "$__fisher_stderr"
            end

            return 1
        end
    end
end


function __fisher_self_uninstall -a yn
    set -l file (status --current-filename)
    set -l u (set_color -u)
    set -l nc (set_color normal)

    switch "$yn"
        case -y --yes
        case \*
            __fisher_log info "
                This will permanently remove fisherman from your system.
                The following directories and files will be erased:

                $fisher_cache
                $fisher_config
                $fish_config/functions/$fisher_cmd_name.fish
                $fish_config/completions/$fisher_cmd_name.fish

            " >&2

            echo -sn "Continue? [Y/n] " >&2

            __fisher_get_key | read -l yn

            switch "$yn"
                case n N
                    set -l username

                    if test ! -z "$USER"
                        set username " $USER"
                    end

                    __fisher_log okay "As you wish cap!"
                    return 1
            end
    end

    complete -c $fisher_cmd_name --erase

    __fisher_show_spinner

    echo "$fisher_cmd_name ls | $fisher_cmd_name rm -q" | source 2> /dev/null

    __fisher_show_spinner

    command rm -rf "$fisher_cache" "$fisher_config"
    command rm -f "$fish_config"/{functions,completions}/$fisher_cmd_name.fish "$fisher_file"

    set -e fish_config
    set -e fish_path
    set -e fisher_active_prompt
    set -e fisher_cache
    set -e fisher_config
    set -e fisher_file
    set -e fisher_version
    set -e fisher_spinners

    __fisher_log info "Done." "$__fisher_stderr"

    set -l funcs (functions -a | command grep __fisher)

    functions -e $funcs $fisher_cmd_name
end


function __fisher_man_page_write
    echo  '.
.TH "FISHERMAN" "1" "May 2016" "" "fisherman"
.
.SH "NAME"
\fBfisherman\fR \- fish plugin manager
.
.SH "SYNOPSIS"
'"$fisher_cmd_name"' [(\fBi\fRnstall | \fBu\fRpdate | \fBl\fRs[\-remote] | \fBr\fRm | \fBh\fRelp) PLUGINS]
.
.br
.
.SH "DESCRIPTION"
A plugin manager for fish\.
.
.SH "OPTIONS"
.
.IP "\(bu" 4
\-v, \-\-version: Show version information\.
.
.IP "\(bu" 4
\-h, \-\-help: Show usage help\. Use the long form to display this page\.
.
.IP "\(bu" 4
\-q, \-\-quiet: Enable quiet mode\. Use to suppress output\.
.
.IP "" 0
.
.SH "USAGE"
Install a plugin\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' mono
.
.fi
.
.IP "" 0
.
.P
Install some plugins\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' z fzf edc/bass omf/tab
.
.fi
.
.IP "" 0
.
.P
Install a specific branch\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' edc/bass:master
.
.fi
.
.IP "" 0
.
.P
Install a specific tag\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' done@1.2.0
.
.fi
.
.IP "" 0
.
.P
Install a gist\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' https://gist\.github\.com/username/1f40e1c6e0551b2666b2
.
.fi
.
.IP "" 0
.
.P
Install a local directory\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' ~/my/plugin
.
.fi
.
.IP "" 0
.
.P
Edit your \fIfishfile\fR and run \fB'"$fisher_cmd_name"'\fR to commit changes\.
.
.IP "" 4
.
.nf

$EDITOR ~/\.config/fish/fishfile
'"$fisher_cmd_name"'
.
.fi
.
.IP "" 0
.
.P
Show everything you\'ve installed\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' ls
@ plugin     # a local directory
* mono       # the current prompt
  bass
  fzf
  thefuck
  z
.
.fi
.
.IP "" 0
.
.P
Show everything that\'s available\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' ls\-remote
.
.fi
.
.IP "" 0
.
.P
Update everything\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' up
.
.fi
.
.IP "" 0
.
.P
Update some plugins\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' up bass z fzf
.
.fi
.
.IP "" 0
.
.P
Remove plugins\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' rm thefuck
.
.fi
.
.IP "" 0
.
.P
Remove all the plugins\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' ls | '"$fisher_cmd_name"' rm
.
.fi
.
.IP "" 0
.
.P
Get help\.
.
.IP "" 4
.
.nf

'"$fisher_cmd_name"' help z
.
.fi
.
.IP "" 0
.
.SH "FAQ"
.
.SS "What is the required fish version?"
>=2\.2\.0\.
.
.P
For \fIsnippet\fR support, upgrade to >=2\.3\.0 or append the following code to your \fI~/\.config/fish/config\.fish\fR\.
.
.IP "" 4
.
.nf

for file in ~/\.config/fish/conf\.d/*\.fish
    source $file
end
.
.fi
.
.IP "" 0
.
.SS "Is fisherman compatible with oh\-my\-fish themes and plugins?"
Yes\.
.
.SS "Where does fisherman put stuff?"
The cache and configuration go in \fI~/\.cache/fisherman\fR and \fI~/\.config/fisherman\fR respectively\.
.
.P
The fishfile is saved to \fI~/\.config/fish/fishfile\fR\.
.
.SS "How do I have fisherman copy plugin files instead of linking?"
By default, fisherman will create symlinks to plugin files.
.
.P
To have fisherman copy files:
.
.IP "" 4
.
.nf=

set -U fisher_copy true
.
.fi
.
.IP "" 0
.
.SS "What is a fishfile and how do I use it?"
The fishfile \fI~/\.config/fish/fishfile\fR lists what plugins you\'ve installed\.
.
.P
This file is updated automatically as you install / remove plugins. You can also edit this file and run \fBfisher\fR to commit changes\.
.
.P
This mechanism only installs plugins and missing dependencies\. To remove plugins, use \fBfisher rm\fR\.
.
.SS "What is a plugin?"
A plugin is:
.
.IP "1." 4
a directory or git repo with one or more \fI\.fish\fR functions either at the root level of the project or inside a \fIfunctions\fR directory
.
.IP "2." 4
a theme or prompt, i\.e, a \fIfish_prompt\.fish\fR, \fIfish_right_prompt\.fish\fR or both files
.
.IP "3." 4
a snippet, i\.e, one or more \fI\.fish\fR files inside a directory named \fIconf\.d\fR, evaluated by fish at the start of the session
.
.IP "" 0
.
.SS "How can I list plugins as dependencies to my plugin?"
Create a new \fIfishfile\fR file at the root level of your project and write in the plugins\.'
end