this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ignore fin.fish

+1 -1951
+1
fish/functions/.gitignore
··· 1 + fin.fish
-1951
fish/functions/fin.fish
··· 1 - # The MIT License (MIT) 2 - # 3 - # Copyright (c) 2016 Jorge Bucaran 4 - # 5 - # Permission is hereby granted, free of charge, to any person obtaining a copy of 6 - # this software and associated documentation files (the "Software"), to deal in 7 - # the Software without restriction, including without limitation the rights to 8 - # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 - # the Software, and to permit persons to whom the Software is furnished to do so, 10 - # subject to the following conditions: 11 - # 12 - # The above copyright notice and this permission notice shall be included in all 13 - # copies or substantial portions of the Software. 14 - # 15 - # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 - # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 - # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 - # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 - # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 - 22 - 23 - set -g fin_version "1.0.0-beta" 24 - 25 - 26 - function __fin_install 27 - if test -z "$argv" 28 - __fin_read_bundle_file | read -az argv 29 - end 30 - 31 - set -e __fin_fetch_plugins_state 32 - 33 - if set -l fetched (__fin_plugin_fetch_items (__fin_plugin_get_missing $argv)) 34 - if test -z "$fetched" 35 - set -l count (count $argv) 36 - 37 - if test "$count" -eq 1 38 - if test -d "$argv[1]" 39 - set argv[1] (__fin_plugin_normalize_path "$argv[1]") 40 - end 41 - 42 - set -l base (__fin_plugin_get_names "$argv[1]")[1] 43 - 44 - __fin_log warn " 45 - It seems @$base@ is already installed 46 - __""$fin_config/$base""__ 47 - " $__fin_stderr 48 - 49 - else 50 - __fin_log warn "No plugins to install or missing dependencies." $__fin_stderr 51 - 52 - __fin_log says " 53 - 54 - If you tried to install any plugins, it's likely 55 - they are already installed in your shell. To see 56 - what's installed, run @fin ls@. 57 - " $__fin_stderr 58 - end 59 - 60 - return 1 61 - end 62 - 63 - for i in $fetched 64 - __fin_plugin_enable "$fin_config/$i" 65 - end 66 - 67 - else 68 - __fin_log error " 69 - There was an error cloning @$fetched@. 70 - " $__fin_stderr 71 - 72 - __fin_log says " 73 - 74 - You can use a url or prepend a namespace to 75 - the plugin's name, for example: @omf@/$fetched 76 - " $__fin_stderr 77 - 78 - return 1 79 - end 80 - end 81 - 82 - 83 - function __fin_plugin_fetch_items 84 - __fin_show_spinner 85 - 86 - set -l jobs 87 - set -l links 88 - set -l white 89 - set -l count (count $argv) 90 - 91 - if test "$count" -eq 0 92 - return 93 - end 94 - 95 - switch "$__fin_fetch_plugins_state" 96 - case "" 97 - if test "$count" = 1 98 - __fin_log says "Installing @$count@ plugin" $__fin_stderr 99 - else 100 - __fin_log says "Installing @$count@ plugins" $__fin_stderr 101 - end 102 - 103 - set -g __fin_fetch_plugins_state "fetching" 104 - 105 - case "fetching" 106 - __fin_log says "Installing @$count@ dependencies" $__fin_stderr 107 - set -g __fin_fetch_plugins_state "done" 108 - 109 - case "done" 110 - end 111 - 112 - for i in $argv 113 - set -l names 114 - 115 - switch "$i" 116 - case \*gist.github.com\* 117 - __fin_log says "Resolving gist name..." 118 - if not set names (__fin_get_plugin_name_from_gist "$i") "" 119 - __fin_log error " 120 - I couldn't find your gist 121 - @$i@ 122 - " 123 - continue 124 - end 125 - 126 - case \* 127 - set names (__fin_plugin_get_names "$i") 128 - end 129 - 130 - if test -d "$i" 131 - command ln -sfF "$i" "$fin_config/$names[1]" 132 - set links $links "$names[1]" 133 - continue 134 - end 135 - 136 - set -l source "$fin_cache/$names[1]" 137 - 138 - if test -z "$names[2]" 139 - if test -d "$source" 140 - if test -L "$source" 141 - command ln -sfF "$source" "$fin_config" 142 - else 143 - command cp -rf "$source" "$fin_config" 144 - end 145 - else 146 - set jobs $jobs (__fin_plugin_url_clone_async "$i" "$names[1]") 147 - end 148 - else 149 - if test -d "$source" 150 - set -l real_namespace (__fin_plugin_get_url_info --dirname "$source" ) 151 - 152 - if test "$real_namespace" = "$names[2]" 153 - command cp -rf "$source" "$fin_config" 154 - else 155 - set jobs $jobs (__fin_plugin_url_clone_async "$i" "$names[1]") 156 - end 157 - else 158 - set jobs $jobs (__fin_plugin_url_clone_async "$i" "$names[1]") 159 - end 160 - end 161 - 162 - set fetched $fetched "$names[1]" 163 - end 164 - 165 - __fin_jobs_await $jobs 166 - 167 - for i in $fetched 168 - if test ! -d "$fin_cache/$i" 169 - printf "%s\n" "$i" 170 - return 1 171 - end 172 - end 173 - 174 - if test ! -z "$fetched" 175 - __fin_plugin_fetch_items (__fin_plugin_get_missing $fetched) 176 - printf "%s\n" $fetched 177 - end 178 - 179 - if test ! -z "$links" 180 - __fin_plugin_fetch_items (__fin_plugin_get_missing $links) 181 - printf "%s\n" $links 182 - end 183 - end 184 - 185 - 186 - function __fin_plugin_url_clone_async -a url name 187 - switch "$url" 188 - case https://\* 189 - case github.com/\* 190 - set url "https://$url" 191 - 192 - case \?\*/\?\* 193 - set url "https://github.com/$url" 194 - 195 - case \* 196 - set url "https://github.com/fishery/$url" 197 - end 198 - 199 - set -l nc (set_color normal) 200 - set -l red (set_color red) 201 - set -l uline (set_color -u) 202 - set -l green (set_color green) 203 - set -l magenta (set_color magenta) 204 - 205 - set -l hm_url (printf "%s\n" "$url" | sed 's|^https://||') 206 - 207 - fish -c " 208 - set -lx GIT_ASKPASS /bin/echo 209 - 210 - if command git clone -q --depth 1 '$url' '$fin_cache/$name' ^ /dev/null 211 - printf 'fin $green""OKAY""$nc $magenta%18s$nc $uline%s$nc\n' '$name' '$hm_url' 212 - command cp -rf '$fin_cache/$name' '$fin_config' 213 - else 214 - printf 'fin $red""ARGH""$nc $magenta%18s$nc $uline%s$nc\n' '$name' '$hm_url' 215 - end 216 - " > /dev/stderr & 217 - 218 - __fin_jobs_get -l 219 - end 220 - 221 - 222 - function __fin_update 223 - set -l jobs 224 - set -l count (count $argv) 225 - set -l updated 226 - 227 - if test "$count" = 0 228 - return 229 - end 230 - 231 - if test "$count" -eq 1 232 - __fin_log says "Updating @$count@ plugin" $__fin_stderr 233 - else 234 - __fin_log says "Updating @$count@ plugins" $__fin_stderr 235 - end 236 - 237 - for i in $argv 238 - set -l path "$fin_config/$i" 239 - 240 - if test -d "$path" 241 - set updated $updated "$i" 242 - set jobs $jobs (__fin_update_path_async "$i" "$path") 243 - else 244 - __fin_log warn "@$i@ is not installed" 245 - end 246 - end 247 - 248 - __fin_jobs_await $jobs 249 - 250 - set -g __fin_fetch_plugins_state "fetching" 251 - set -l fetched (__fin_plugin_fetch_items (__fin_plugin_get_missing $updated)) 252 - 253 - for i in $updated $fetched 254 - if test "$i" = "$fin_active_prompt" 255 - set fin_active_prompt 256 - end 257 - __fin_plugin_enable "$fin_config/$i" 258 - end 259 - end 260 - 261 - 262 - function __fin_self_update 263 - set -l raw_url "https://raw.githubusercontent.com/fishery/fin/master/fin.fish" 264 - set -l fake_qs (date "+%s") 265 - set -l file (status --current-filename) 266 - 267 - set -l previous_version "$fin_version" 268 - 269 - fish -c "curl --max-time 5 -sS '$raw_url?$fake_qs' > $file.$fake_qs" & 270 - 271 - __fin_jobs_await (__fin_jobs_get -l) 272 - 273 - if test -s "$file.$fake_qs" 274 - command mv "$file.$fake_qs" "$file" 275 - end 276 - 277 - source "$file" 278 - fin -v > /dev/null 279 - set -l new_version "$fin_version" 280 - 281 - if test "$previous_version" = "$fin_version" 282 - __fin_log says "@fin is up to date@" $__fin_stderr 283 - else 284 - __fin_log okay "You are now running fin @$fin_version@" $__fin_stderr 285 - 286 - __fin_log says " 287 - 288 - To see the change log, please visit: 289 - __https://github.com/fishery/fin/releases 290 - " $__fin_stderr 291 - end 292 - end 293 - 294 - 295 - function __fin_update_path_async -a name path 296 - set -l nc (set_color normal) 297 - set -l red (set_color red) 298 - set -l uline (set_color -u) 299 - set -l green (set_color green) 300 - set -l magenta (set_color magenta) 301 - 302 - fish -c " 303 - 304 - pushd $path 305 - 306 - if not command git fetch -q origin master ^ /dev/null 307 - printf 'fin $red""ARGH""$nc $magenta%18s$nc $red✘$nc fetch error\n' '$name' 308 - exit 309 - end 310 - 311 - set -l commits (command git rev-list --left-right --count master..FETCH_HEAD ^ /dev/null | cut -d\t -f2) 312 - 313 - command git reset -q --hard FETCH_HEAD ^ /dev/null 314 - command git clean -qdfx 315 - 316 - if test -z \"\$commits\" -o \"\$commits\" -eq 0 317 - printf 'fin $green""OKAY""$nc $magenta%18s$nc $green•$nc up to date\n' '$name' 318 - command cp -rf '$path' '$fin_cache/$name' 319 - else 320 - printf 'fin $green""OKAY""$nc $magenta%18s$nc $green▸$nc $magenta%s$nc new commits\n' '$name' \$commits 321 - end 322 - 323 - " > /dev/stderr & 324 - 325 - __fin_jobs_get -l 326 - end 327 - 328 - 329 - function __fin_plugin_enable -a path 330 - if __fin_plugin_is_prompt "$path" 331 - if test ! -z "$fin_active_prompt" 332 - __fin_plugin_disable "$fin_config/$fin_active_prompt" 333 - end 334 - 335 - set -U fin_active_prompt (basename "$path") 336 - end 337 - 338 - set -l plugin_name (basename $path) 339 - 340 - for file in $path/{functions/*,}*.fish 341 - set -l base (basename "$file") 342 - 343 - if test "$base" = "uninstall.fish" 344 - continue 345 - end 346 - 347 - switch "$base" 348 - case {,fish_}key_bindings.fish 349 - __fin_key_bindings_append "$plugin_name" "$file" 350 - continue 351 - end 352 - 353 - set -l dir "functions" 354 - 355 - if test "$base" = "init.fish" 356 - set dir "conf.d" 357 - 358 - set base "$plugin_name.$base" 359 - end 360 - 361 - set -l target "$fish_config/$dir/$base" 362 - 363 - command ln -sfF "$file" "$target" 364 - builtin source "$target" 365 - 366 - if test "$base" = "set_color_custom.fish" 367 - printf "%s\n" "$fish_color_normal" "$fish_color_command" "$fish_color_param" "$fish_color_redirection" "$fish_color_comment" "$fish_color_error" "$fish_color_escape" "$fish_color_operator" "$fish_color_end" "$fish_color_quote" "$fish_color_autosuggestion" "$fish_color_user" "$fish_color_valid_path" "$fish_color_cwd" "$fish_color_cwd_root" "$fish_color_match" "$fish_color_search_match" "$fish_color_selection" "$fish_pager_color_prefix" "$fish_pager_color_completion" "$fish_pager_color_description" "$fish_pager_color_progress" "$fish_color_history_current" "$fish_color_host" > "$fish_config/fish_colors" 368 - set_color_custom 369 - end 370 - end 371 - 372 - for file in $path/conf.d/*.{py,awk} 373 - set -l base (basename "$file") 374 - command ln -sfF "$file" "$fish_config/conf.d/$base" 375 - end 376 - 377 - for file in $path/{functions/,}*.{py,awk} 378 - set -l base (basename "$file") 379 - command ln -sfF "$file" "$fish_config/functions/$base" 380 - end 381 - 382 - for file in $path/conf.d/*.fish 383 - set -l base (basename "$file") 384 - set -l target "$fish_config/conf.d/$base" 385 - 386 - command ln -sfF "$file" "$target" 387 - builtin source "$target" 388 - end 389 - 390 - for file in $path/completions/*.fish 391 - set -l base (basename "$file") 392 - set -l target "$fish_config/completions/$base" 393 - 394 - command ln -sfF "$file" "$target" 395 - builtin source "$target" 396 - end 397 - 398 - return 0 399 - end 400 - 401 - 402 - function __fin_plugin_disable -a path 403 - set -l plugin_name (basename $path) 404 - 405 - for file in $path/{functions/*,}*.fish 406 - set -l name (basename "$file" .fish) 407 - set -l base "$name.fish" 408 - 409 - if test "$base" = "uninstall.fish" 410 - builtin source "$file" 411 - continue 412 - end 413 - 414 - switch "$base" 415 - case {,fish_}key_bindings.fish 416 - __fin_key_bindings_remove "$plugin_name" 417 - continue 418 - end 419 - 420 - set -l dir "functions" 421 - 422 - if test "$base" = "init.fish" 423 - set dir "conf.d" 424 - set base "$plugin_name.$base" 425 - end 426 - 427 - command rm -f "$fish_config/$dir/$base" 428 - 429 - functions -e "$name" 430 - 431 - if test "$base" = "set_color_custom.fish" 432 - set -l fish_colors_config "$fish_config/fish_colors" 433 - 434 - if test ! -f "$fish_colors_config" 435 - __fin_reset_default_fish_colors 436 - continue 437 - end 438 - 439 - set -l IFS \n 440 - 441 - read -laz colors < $fish_colors_config 442 - set colors[25] "" 443 - 444 - set -l IFS " " 445 - 446 - echo "$colors[1]" | read -a -U fish_color_normal 447 - echo "$colors[2]" | read -a -U fish_color_command 448 - echo "$colors[3]" | read -a -U fish_color_param 449 - echo "$colors[4]" | read -a -U fish_color_redirection 450 - echo "$colors[5]" | read -a -U fish_color_comment 451 - echo "$colors[6]" | read -a -U fish_color_error 452 - echo "$colors[7]" | read -a -U fish_color_escape 453 - echo "$colors[8]" | read -a -U fish_color_operator 454 - echo "$colors[9]" | read -a -U fish_color_end 455 - echo "$colors[10]" | read -a -U fish_color_quote 456 - echo "$colors[11]" | read -a -U fish_color_autosuggestion 457 - echo "$colors[12]" | read -a -U fish_color_user 458 - echo "$colors[13]" | read -a -U fish_color_valid_path 459 - echo "$colors[14]" | read -a -U fish_color_cwd 460 - echo "$colors[15]" | read -a -U fish_color_cwd_root 461 - echo "$colors[16]" | read -a -U fish_color_match 462 - echo "$colors[17]" | read -a -U fish_color_search_match 463 - echo "$colors[18]" | read -a -U fish_color_selection 464 - echo "$colors[19]" | read -a -U fish_pager_color_prefix 465 - echo "$colors[20]" | read -a -U fish_pager_color_completion 466 - echo "$colors[21]" | read -a -U fish_pager_color_description 467 - echo "$colors[22]" | read -a -U fish_pager_color_progress 468 - echo "$colors[23]" | read -a -U fish_color_history_current 469 - echo "$colors[24]" | read -a -U fish_color_host 470 - 471 - command rm -f $fish_colors_config 472 - end 473 - end 474 - 475 - for file in $path/conf.d/*.{py,awk} 476 - set -l base (basename "$file") 477 - command rm -f "$fish_config/conf.d/$base" 478 - end 479 - 480 - for file in $path/{functions/,}*.{py,awk} 481 - set -l base (basename "$file") 482 - command rm -f "$fish_config/functions/$base" 483 - end 484 - 485 - for file in $path/conf.d/*.fish 486 - set -l base (basename "$file") 487 - command rm -f "$fish_config/conf.d/$base" 488 - end 489 - 490 - for file in $path/completions/*.fish 491 - set -l name (basename "$file" .fish) 492 - set -l base "$name.fish" 493 - 494 - command rm -f "$fish_config/completions/$base" 495 - complete -c "$name" --erase 496 - end 497 - 498 - if __fin_plugin_is_prompt "$path" 499 - set -U fin_active_prompt 500 - builtin source $__fish_datadir/functions/fish_prompt.fish ^ /dev/null 501 - end 502 - 503 - command rm -rf "$path" > /dev/stderr 504 - end 505 - 506 - 507 - function __fin_get_plugin_name_from_gist -a url 508 - set -l gist_id (printf "%s\n" "$url" | command sed 's|.*/||') 509 - set -l name (fish -c " 510 - 511 - fin -v > /dev/null 512 - curl -Ss https://api.github.com/gists/$gist_id & 513 - 514 - __fin_jobs_await (__fin_jobs_get -l) 515 - 516 - " | command awk ' 517 - 518 - /"files": / { 519 - files++ 520 - } 521 - 522 - /"[^ ]+.fish": / && files { 523 - gsub("^ *\"|\.fish.*", "") 524 - print 525 - } 526 - 527 - ') 528 - 529 - if test -z "$name" 530 - return 1 531 - end 532 - 533 - printf "%s\n" $name 534 - end 535 - 536 - 537 - function __fin_list 538 - set -l config $fin_config/* 539 - 540 - if test -z "$config" 541 - return 1 542 - end 543 - 544 - set -l white 545 - set -l links (command find $config -maxdepth 0 -type l ! -name "$fin_active_prompt" ^ /dev/null) 546 - set -l names (command find $config -maxdepth 0 -type d ! -name "$fin_active_prompt" ^ /dev/null) 547 - 548 - if test ! -z "$links" 549 - set white " " 550 - printf "%s\n" $links | command sed "s|.*/|@ |" 551 - end 552 - 553 - if test ! -z "$fin_active_prompt" 554 - set white " " 555 - printf "* %s\n" "$fin_active_prompt" 556 - end 557 - 558 - if test ! -z "$names" 559 - printf "%s\n" $names | command sed "s|.*/|$white|" 560 - end 561 - end 562 - 563 - 564 - function __fin_list_plugin_directory -a item 565 - set -l fd $__fin_stderr 566 - 567 - set -e argv[1] 568 - set -l path "$fin_config/$item" 569 - 570 - if test ! -d "$path" 571 - __fin_log error "$item is not installed" $__fin_stderr 572 - 573 - return 1 574 - end 575 - 576 - pushd "$path" 577 - 578 - set -l color (set_color $fish_color_command) 579 - set -l nc (set_color normal) 580 - set -l inside_tree 581 - 582 - if contains -- --no-color $argv 583 - set color 584 - set nc 585 - set fd $__fin_stdout 586 - end 587 - 588 - printf "$color%s$nc\n" "$PWD" > $fd 589 - 590 - for file in .* ** 591 - if test -f "$file" 592 - switch "$file" 593 - case .\* 594 - printf " %s\n" $file 595 - set inside_tree 596 - 597 - case \*/\* 598 - if test -z "$inside_tree" 599 - printf " $color%s/$nc\n" (dirname $file) 600 - set inside_tree - 601 - end 602 - printf " %s\n" (basename $file) 603 - 604 - case \* 605 - printf " %s\n" $file 606 - set inside_tree 607 - end 608 - end 609 - end > $fd 610 - 611 - popd 612 - end 613 - 614 - 615 - function __fin_log -a log message fd 616 - set -l nc (set_color normal) 617 - set -l red (set_color red) 618 - set -l warn (set_color black -b yellow) 619 - set -l green (set_color green) 620 - set -l bold (set_color magenta) 621 - set -l uline (set_color -u) 622 - 623 - switch "$fd" 624 - case "/dev/null" 625 - return 626 - 627 - case "" "/dev/stderr" 628 - set fd "/dev/stderr" 629 - 630 - case \* 631 - set nc "" 632 - set red "" 633 - set warn "" 634 - set green "" 635 - set bold "" 636 - set uline 637 - end 638 - 639 - printf "%s\n" "$message" | command awk ' 640 - function okay(name, s) { 641 - printf("'$nc'%s '$green'%s'$nc' %s\n", name, "OKAY", s) 642 - } 643 - 644 - function says(name, s) { 645 - printf("'$nc'%s '$green'%s'$nc' %s\n", name, "SAYS", s) 646 - } 647 - 648 - function warn(name, s) { 649 - printf("'$nc'%s '$warn'%s'$nc' %s\n", name, "WARN", s) 650 - } 651 - 652 - function error(name, s) { 653 - printf("'$nc'%s '$red'%s'$nc' %s\n", name, "ARGH", s) 654 - } 655 - 656 - { 657 - sub(/^[ ]+/, "") 658 - gsub("``", " ") 659 - 660 - if (/@[^@]+@/) { 661 - n = match($0, /@[^@]+@/) 662 - if (n) { 663 - sub(/@[^@]+@/, "'$bold'" substr($0, RSTART + 1, RLENGTH - 2) "'$nc'", $0) 664 - } 665 - } 666 - 667 - if (/__[^_]+__/) { 668 - n = match($0, /__[^_]+__/) 669 - if (n) { 670 - sub(/__[^_]+__/, "'$uline'" substr($0, RSTART + 2, RLENGTH - 4) "'$nc'", $0) 671 - } 672 - } 673 - 674 - s[++len] = $0 675 - } 676 - 677 - END { 678 - for (i = 1; i <= len; i++) { 679 - if ((i == 1 || i == len) && (s[i] == "")) { 680 - continue 681 - } 682 - 683 - if (s[i] == "") { 684 - print 685 - } else { 686 - '$log'("fin", s[i]) 687 - } 688 - } 689 - } 690 - 691 - ' > "$fd" 692 - end 693 - 694 - 695 - function __fin_log_error_footer -a fd 696 - set -l url "https://github.com/fishery/fin/issues" 697 - set -l debug_log "$fin_cache/fin-debug.log" 698 - 699 - __fin_log error " 700 - For more help, visit the issue tracker 701 - @$url@ 702 - `` 703 - Include the following file with your issue 704 - @$debug_log@ 705 - " $fd 706 - end 707 - 708 - 709 - function __fin_jobs_get 710 - jobs $argv | command awk -v FS=\t ' 711 - /[0-9]+\t/{ 712 - jobs[++job_count] = $1 713 - } 714 - 715 - END { 716 - for (i = 1; i <= job_count; i++) { 717 - print(jobs[i]) 718 - } 719 - 720 - exit job_count == 0 721 - } 722 - ' 723 - end 724 - 725 - 726 - function __fin_jobs_await 727 - if test -z "$argv" 728 - return 729 - end 730 - 731 - while true 732 - for spinner in $fin_spinners 733 - printf " $spinner \r" > /dev/stderr 734 - sleep 0.04 735 - end 736 - 737 - set -l currently_active_jobs (__fin_jobs_get) 738 - 739 - if test -z "$currently_active_jobs" 740 - break 741 - end 742 - 743 - set -l has_jobs 744 - 745 - for i in $argv 746 - if builtin contains -- $i $currently_active_jobs 747 - set has_jobs "*" 748 - break 749 - end 750 - end 751 - 752 - if test -z "$has_jobs" 753 - break 754 - end 755 - end 756 - end 757 - 758 - 759 - function __fin_key_bindings_remove -a plugin_name 760 - set -l user_key_bindings "$fish_config/functions/fish_user_key_bindings.fish" 761 - set -l tmp (date "+%s") 762 - 763 - fish_indent < "$user_key_bindings" | sed -n "/### $plugin_name ###/,/### $plugin_name ###/{s/^ *bind /bind -e /p;};" > shit #| source ^ /dev/null 764 - 765 - sed "/### $plugin_name ###/,/### $plugin_name ###/d" < "$user_key_bindings" > "$user_key_bindings.$tmp" 766 - command mv -f "$user_key_bindings.$tmp" "$user_key_bindings" 767 - 768 - if awk ' 769 - /^$/ { next } 770 - 771 - /^function fish_user_key_bindings/ { 772 - i++ 773 - next 774 - } 775 - 776 - /^end$/ && 1 == i { 777 - exit 0 778 - } 779 - 780 - // { 781 - exit 1 782 - } 783 - 784 - ' < "$user_key_bindings" 785 - 786 - command rm -f "$user_key_bindings" 787 - end 788 - end 789 - 790 - 791 - function __fin_key_bindings_append -a plugin_name file 792 - set -l user_key_bindings "$fish_config/functions/fish_user_key_bindings.fish" 793 - 794 - command mkdir -p (dirname "$user_key_bindings") 795 - touch "$user_key_bindings" 796 - 797 - set -l key_bindings_source ( 798 - fish_indent < "$user_key_bindings" | awk ' 799 - 800 - /^function fish_user_key_bindings/ { 801 - reading_function_source = 1 802 - next 803 - } 804 - 805 - /^end$/ { 806 - exit 807 - } 808 - 809 - reading_function_source { 810 - print $0 811 - next 812 - } 813 - 814 - ' 815 - ) 816 - 817 - set -l plugin_key_bindings_source ( 818 - fish_indent < "$file" | awk -v name="$plugin_name" ' 819 - 820 - BEGIN { 821 - printf("### %s ###\n", name) 822 - } 823 - 824 - END { 825 - printf("### %s ###\n", name) 826 - } 827 - 828 - /^function fish_user_key_bindings$/ { 829 - check_for_and_keyword = 1 830 - next 831 - } 832 - 833 - /^end$/ && check_for_and_keyword { 834 - end = 0 835 - next 836 - } 837 - 838 - !/^ *(#.*)*$/ { 839 - gsub("#.*", "") 840 - printf("%s\n", $0) 841 - } 842 - 843 - ' 844 - ) 845 - 846 - printf "%s\n" $key_bindings_source $plugin_key_bindings_source | awk ' 847 - 848 - BEGIN { 849 - print "function fish_user_key_bindings" 850 - } 851 - 852 - // 853 - 854 - END { 855 - print "end" 856 - } 857 - 858 - ' | fish_indent > "$user_key_bindings" 859 - end 860 - 861 - 862 - function __fin_plugin_is_prompt -a path 863 - if test -e $path/fish_prompt.fish 864 - return 865 - end 866 - 867 - if test -e $path/functions/fish_prompt.fish 868 - return 869 - end 870 - 871 - if test -e $path/fish_right_prompt.fish 872 - return 873 - end 874 - 875 - if test -e $path/functions/fish_right_prompt.fish 876 - return 877 - end 878 - 879 - return 1 880 - end 881 - 882 - 883 - function __fin_plugin_get_names 884 - printf "%s\n" $argv | command awk ' 885 - 886 - { 887 - sub(/\/$/, "") 888 - n = split($0, s, "/") 889 - sub(/^(omf|omf-theme|omf-plugin|plugin|theme|fish|fisher)-/, "", s[n]) 890 - 891 - printf("%s\n%s\n", s[n], s[n - 1]) 892 - } 893 - 894 - ' 895 - end 896 - 897 - 898 - function __fin_plugin_get_url_info -a option 899 - set -e argv[1] 900 - 901 - if test -z "$argv" 902 - return 903 - end 904 - 905 - cat {$argv}/.git/config ^ /dev/null | command awk -v option="$option" ' 906 - /url/ { 907 - n = split($3, s, "/") 908 - 909 - if ($3 ~ /https:\/\/gist/) { 910 - printf("# %s\n", $3) 911 - next 912 - } 913 - 914 - if (option == "--dirname") { 915 - printf("%s\n", s[n - 1]) 916 - 917 - } else if (option == "--basename") { 918 - printf("%s\n", s[n]) 919 - 920 - } else { 921 - printf("%s/%s\n", s[n - 1], s[n]) 922 - } 923 - } 924 - ' 925 - end 926 - 927 - 928 - function __fin_plugin_normalize_path 929 - printf "%s\n" $argv | command awk -v pwd="$PWD" ' 930 - 931 - /^\.$/ { 932 - print(pwd) 933 - next 934 - } 935 - 936 - /^\// { 937 - sub(/\/$/, "") 938 - print($0) 939 - next 940 - } 941 - 942 - { 943 - sub(/\/$/, "") 944 - n = split($0, a, "/") 945 - print(pwd "/" (n > 1 ? a[n - 1] "/" : "") a[n]) 946 - 947 - next 948 - } 949 - 950 - ' 951 - end 952 - 953 - 954 - function __fin_plugin_get_missing 955 - for i in $argv 956 - if test -d "$i" 957 - set i (__fin_plugin_normalize_path "$i") 958 - end 959 - 960 - set -l name (__fin_plugin_get_names "$i")[1] 961 - 962 - if set -l path (__fin_plugin_is_installed "$name") 963 - for file in fishfile bundle 964 - if test -s "$path/$file" 965 - __fin_plugin_get_missing (__fin_read_bundle_file < "$path/$file") 966 - end 967 - end 968 - else 969 - printf "%s\n" "$i" 970 - end 971 - end 972 - 973 - __fin_show_spinner 974 - end 975 - 976 - 977 - function __fin_plugin_is_installed -a name 978 - if test -z "$name" -o ! -d "$fin_config/$name" 979 - return 1 980 - end 981 - 982 - printf "%s\n" "$fin_config/$name" 983 - end 984 - 985 - 986 - function __fin_reset_default_fish_colors 987 - set -U fish_color_normal normal 988 - set -U fish_color_command 005fd7 purple 989 - set -U fish_color_param 00afff cyan 990 - set -U fish_color_redirection 005fd7 991 - set -U fish_color_comment 600 992 - set -U fish_color_error red --bold 993 - set -U fish_color_escape cyan 994 - set -U fish_color_operator cyan 995 - set -U fish_color_end green 996 - set -U fish_color_quote brown 997 - set -U fish_color_autosuggestion 555 yellow 998 - set -U fish_color_user green 999 - set -U fish_color_valid_path --underline 1000 - set -U fish_color_cwd green 1001 - set -U fish_color_cwd_root red 1002 - set -U fish_color_match cyan 1003 - set -U fish_color_search_match --background=purple 1004 - set -U fish_color_selection --background=purple 1005 - set -U fish_pager_color_prefix cyan 1006 - set -U fish_pager_color_completion normal 1007 - set -U fish_pager_color_description 555 yellow 1008 - set -U fish_pager_color_progress cyan 1009 - set -U fish_color_history_current cyan 1010 - set -U fish_color_host normal 1011 - end 1012 - 1013 - 1014 - function __fin_read_bundle_file 1015 - command awk -v FS=\t ' 1016 - /^$/ || /^[ \t]*#/ { 1017 - next 1018 - } 1019 - 1020 - /^[ \t]*package / { 1021 - sub("^[ \t]*package ", "oh-my-fish/plugin-") 1022 - } 1023 - 1024 - { 1025 - sub("^[@* \t]*", "") 1026 - 1027 - if (!seen[$0]++) { 1028 - printf("%s\n", $0) 1029 - } 1030 - } 1031 - ' 1032 - end 1033 - 1034 - 1035 - function __fin_completions_write 1036 - functions __fin_completions_write | fish_indent | __fin_parse_comments_from_function 1037 - 1038 - # complete -xc fin -s h -l help -d "Show usage help" 1039 - # complete -xc fin -s q -l quiet -d "Enable quiet mode" 1040 - # complete -xc fin -s v -l version -d "Show version information" 1041 - # complete -xc fin -n "__fish_use_subcommand" -a install -d "Install plugins / i" 1042 - # complete -xc fin -n "__fish_use_subcommand" -a update -d "Update fin and plugins / u" 1043 - # complete -xc fin -n "__fish_use_subcommand" -a rm -d "Remove plugins / r" 1044 - # complete -xc fin -n "__fish_use_subcommand" -a ls -d "List plugins / l" 1045 - # complete -xc fin -n "__fish_use_subcommand" -a help -d "Show help / h" 1046 - end 1047 - 1048 - 1049 - function __fin_humanize_duration 1050 - awk ' 1051 - function hmTime(time, stamp) { 1052 - split("h:m:s:ms", units, ":") 1053 - 1054 - for (i = 2; i >= -1; i--) { 1055 - if (t = int( i < 0 ? time % 1000 : time / (60 ^ i * 1000) % 60 )) { 1056 - stamp = stamp t units[sqrt((i - 2) ^ 2) + 1] " " 1057 - } 1058 - } 1059 - 1060 - if (stamp ~ /^ *$/) { 1061 - return "0ms" 1062 - } 1063 - 1064 - return substr(stamp, 1, length(stamp) - 1) 1065 - } 1066 - 1067 - { 1068 - print hmTime($0) 1069 - } 1070 - ' 1071 - end 1072 - 1073 - 1074 - function __fin_get_key 1075 - stty -icanon -echo ^ /dev/null 1076 - 1077 - printf "$argv" > /dev/stderr 1078 - 1079 - while true 1080 - dd bs=1 count=1 ^ /dev/null | read -p "" -l yn 1081 - 1082 - switch "$yn" 1083 - case y Y n N 1084 - printf "\n" > /dev/stderr 1085 - printf "%s\n" $yn > /dev/stdout 1086 - break 1087 - end 1088 - end 1089 - 1090 - stty icanon echo > /dev/stderr ^ /dev/null 1091 - end 1092 - 1093 - 1094 - function __fin_get_epoch_in_ms -a elapsed 1095 - if test -z "$elapsed" 1096 - set elapsed 0 1097 - end 1098 - 1099 - perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - '$elapsed')' 1100 - end 1101 - 1102 - 1103 - function __fin_parse_column_output 1104 - command awk -v FS=\t ' 1105 - { 1106 - 1107 - for (i = 1; i <= NF; i++) { 1108 - if ($i != "") { 1109 - print $i 1110 - } 1111 - } 1112 - 1113 - } 1114 - ' 1115 - end 1116 - 1117 - 1118 - function __fin_parse_comments_from_function 1119 - command awk ' 1120 - 1121 - /^[\t ]*# ?/ { 1122 - sub(/^[\t ]*# ?/, "") 1123 - a[++n] = $0 1124 - } 1125 - 1126 - END { 1127 - for (i = 1; i <= n; i++) { 1128 - printf("%s\n", a[i]) 1129 - } 1130 - } 1131 - 1132 - ' 1133 - end 1134 - 1135 - 1136 - function __fin_usage 1137 - set -l u (set_color -u) 1138 - set -l nc (set_color normal) 1139 - 1140 - echo "Usage: fin [<command>] [<plugins>] [--quiet] [--version]" 1141 - echo 1142 - echo "where <command> can be one of:" 1143 - echo " "$u"i"$nc"nstall (default)" 1144 - echo " "$u"u"$nc"pdate" 1145 - echo " "$u"r"$nc"m" 1146 - echo " "$u"l"$nc"s" 1147 - echo " "$u"h"$nc"elp" 1148 - end 1149 - 1150 - 1151 - function __fin_help -a command number 1152 - if test -z "$argv" 1153 - set -l page "$fin_cache/fin.1" 1154 - 1155 - if test ! -s "$page" 1156 - __fin_man_page_write > "$page" 1157 - end 1158 - 1159 - set -l pager "/usr/bin/less -s" 1160 - 1161 - if test ! -z "$PAGER" 1162 - set pager "$PAGER" 1163 - end 1164 - 1165 - man -P "$pager" -- "$page" 1166 - 1167 - command rm -f "$page" 1168 - 1169 - else 1170 - if test -z "$number" 1171 - set number 1 1172 - end 1173 - 1174 - set -l page "$fin_config/$command/man/man$number/$command.$number" 1175 - 1176 - if not man "$page" ^ /dev/null 1177 - __fin_log error "No manual entry for $command" $__fin_stderr 1178 - 1179 - if test -d "$fin_config/$command" 1180 - set -l url (__fin_plugin_get_url_info -- $fin_config/$command) 1181 - 1182 - if test ! -z "$url" 1183 - __fin_log says "Visit the online repository for help:" $__fin_stderr 1184 - __fin_log says "__https://github.com/$url" $__fin_stderr 1185 - end 1186 - else 1187 - __fin_log error "$command is not installed" $__fin_stderr 1188 - end 1189 - 1190 - return 1 1191 - end 1192 - end 1193 - end 1194 - 1195 - 1196 - function __fin_man_page_write 1197 - functions __fin_man_page_write | fish_indent | __fin_parse_comments_from_function 1198 - 1199 - # . 1200 - # .TH "FIN" "1" "April 2016" "" "fin" 1201 - # . 1202 - # .SH "NAME" 1203 - # \fBfin\fR \- fish plugin manager 1204 - # . 1205 - # .SH "SYNOPSIS" 1206 - # fin [\fIcommand\fR] [\fIplugins\fR] [\-\-quiet] [\-\-version] 1207 - # . 1208 - # .br 1209 - # . 1210 - # .SH "DESCRIPTION" 1211 - # fin is a one\-file, no\-configuration, concurrent plugin manager for the fish shell\. 1212 - # . 1213 - # .SH "USAGE" 1214 - # Install a plugin\. 1215 - # . 1216 - # .IP "" 4 1217 - # . 1218 - # .nf 1219 - # 1220 - # fin superman 1221 - # . 1222 - # .fi 1223 - # . 1224 - # .IP "" 0 1225 - # . 1226 - # .P 1227 - # Install from multiple sources\. 1228 - # . 1229 - # .IP "" 4 1230 - # . 1231 - # .nf 1232 - # 1233 - # fin omf/{grc,thefuck} fzf z 1234 - # . 1235 - # .fi 1236 - # . 1237 - # .IP "" 0 1238 - # . 1239 - # .P 1240 - # Install from a URL\. 1241 - # . 1242 - # .IP "" 4 1243 - # . 1244 - # .nf 1245 - # 1246 - # fin https://github\.com/edc/bass 1247 - # . 1248 - # .fi 1249 - # . 1250 - # .IP "" 0 1251 - # . 1252 - # .P 1253 - # Install from a gist\. 1254 - # . 1255 - # .IP "" 4 1256 - # . 1257 - # .nf 1258 - # 1259 - # fin https://gist\.github\.com/username/1f40e1c6e0551b2666b2 1260 - # . 1261 - # .fi 1262 - # . 1263 - # .IP "" 0 1264 - # . 1265 - # .P 1266 - # Install from a local directory\. 1267 - # . 1268 - # .IP "" 4 1269 - # . 1270 - # .nf 1271 - # 1272 - # fin ~/my_aliases 1273 - # . 1274 - # .fi 1275 - # . 1276 - # .IP "" 0 1277 - # . 1278 - # .P 1279 - # Use it a la vundle\. Edit \fB~/\.config/fish/bundle\fR and run \fBfin\fR to satisfy the changes\. 1280 - # . 1281 - # .IP "" 4 1282 - # . 1283 - # .nf 1284 - # 1285 - # $EDITOR ~/\.config/fish/bundle # add plugins 1286 - # fin 1287 - # . 1288 - # .fi 1289 - # . 1290 - # .IP "" 0 1291 - # . 1292 - # .P 1293 - # See what\'s installed\. 1294 - # . 1295 - # .IP "" 4 1296 - # . 1297 - # .nf 1298 - # 1299 - # fin ls 1300 - # @ my_aliases # this plugin is a local directory 1301 - # * superman # this plugin is the current prompt 1302 - # bass 1303 - # fzf 1304 - # grc 1305 - # thefuck 1306 - # z 1307 - # . 1308 - # .fi 1309 - # . 1310 - # .IP "" 0 1311 - # . 1312 - # .P 1313 - # Update everything\. 1314 - # . 1315 - # .IP "" 4 1316 - # . 1317 - # .nf 1318 - # 1319 - # fin update 1320 - # . 1321 - # .fi 1322 - # . 1323 - # .IP "" 0 1324 - # . 1325 - # .P 1326 - # Update some plugins\. 1327 - # . 1328 - # .IP "" 4 1329 - # . 1330 - # .nf 1331 - # 1332 - # fin update bass z fzf thefuck 1333 - # . 1334 - # .fi 1335 - # . 1336 - # .IP "" 0 1337 - # . 1338 - # .P 1339 - # Remove plugins\. 1340 - # . 1341 - # .IP "" 4 1342 - # . 1343 - # .nf 1344 - # 1345 - # fin rm superman 1346 - # . 1347 - # .fi 1348 - # . 1349 - # .IP "" 0 1350 - # . 1351 - # .P 1352 - # Remove everything\. 1353 - # . 1354 - # .IP "" 4 1355 - # . 1356 - # .nf 1357 - # 1358 - # fin ls | fin rm 1359 - # . 1360 - # .fi 1361 - # . 1362 - # .IP "" 0 1363 - # . 1364 - # .P 1365 - # Get help\. 1366 - # . 1367 - # .IP "" 4 1368 - # . 1369 - # .nf 1370 - # 1371 - # fin help z 1372 - # . 1373 - # .fi 1374 - # . 1375 - # .IP "" 0 1376 - # . 1377 - # .SH "FAQ" 1378 - # . 1379 - # .SS "1\. How do I uninstall fin?" 1380 - # Run 1381 - # . 1382 - # .IP "" 4 1383 - # . 1384 - # .nf 1385 - # 1386 - # fin self\-destroy 1387 - # . 1388 - # .fi 1389 - # . 1390 - # .IP "" 0 1391 - # . 1392 - # .SS "2\. What fish version is required?" 1393 - # fin was built for the latest fish, but at least 2\.2\.0 is required\. If you can\'t upgrade your build, append the following code to your \fB~/\.config/fish/config\.fish\fR for snippet \fIhttps://github\.com/fishery/fin/blob/master/faq\.md#12\-what\-is\-a\-plugin\fR support\. 1394 - # . 1395 - # .IP "" 4 1396 - # . 1397 - # .nf 1398 - # 1399 - # for file in ~/\.config/fish/conf\.d/*\.fish 1400 - # source $file 1401 - # end 1402 - # . 1403 - # .fi 1404 - # . 1405 - # .IP "" 0 1406 - # . 1407 - # .SS "3\. Is fin compatible with fisherman and oh my fish themes and plugins?" 1408 - # Yes\. 1409 - # . 1410 - # .SS "4\. Why fin? Why not ____?" 1411 - # fin learns from my mistakes building oh my fish, wahoo and fisherman\. It also takes some ideas from fundle and chips\. 1412 - # . 1413 - # .P 1414 - # Other reasons: 1415 - # . 1416 - # .IP "\(bu" 4 1417 - # fast and easy to install, update and uninstall 1418 - # . 1419 - # .IP "\(bu" 4 1420 - # small and fits in one file 1421 - # . 1422 - # .IP "\(bu" 4 1423 - # you don\'t need to modify your fish configuration to use it 1424 - # . 1425 - # .IP "\(bu" 4 1426 - # framework agnostic, no favorites 1427 - # . 1428 - # .IP "\(bu" 4 1429 - # zero impact on shell startup time 1430 - # . 1431 - # .IP "" 0 1432 - # . 1433 - # .SS "5\. Where does fin put stuff?" 1434 - # fin usually goes in \fB~/\.config/fish/functions/fin\.fish\fR\. 1435 - # . 1436 - # .P 1437 - # The cache and plugin configuration is created in \fB~/\.cache/fin\fR and \fB~/\.config/fin\fR respectively\. 1438 - # . 1439 - # .P 1440 - # The \fBbundle\fR file is stored in \fB~/\.config/fish\fR\. 1441 - # . 1442 - # .SS "6\. What is a bundle file and how do I use it?" 1443 - # The bundle file lists all the installed plugins\. 1444 - # . 1445 - # .P 1446 - # You can let fin take care of the bundle for you automatically, or write in the plugins you want and run \fBfin\fR to satisfy the changes\. 1447 - # . 1448 - # .IP "" 4 1449 - # . 1450 - # .nf 1451 - # 1452 - # fishery/superman 1453 - # omf/grc 1454 - # omf/thefuck 1455 - # fishery/z 1456 - # . 1457 - # .fi 1458 - # . 1459 - # .IP "" 0 1460 - # . 1461 - # .P 1462 - # This mechanism only installs plugins and missing dependencies\. To remove a plugin, use \fBfin rm\fR instead\. 1463 - # . 1464 - # .P 1465 - # The bundle file is inside your fish configuration directory \fB~/\.config/fish\fR so you can commit the entire tree to your dotfiles or only the bundle and that\'s it\. 1466 - # . 1467 - # .SS "7\. Where can I find a list of fish plugins?" 1468 - # Browse github/fishery, github/oh\-my\-fish, github/awesome\-fish or use the http://fisherman.sh online search to discover content\. 1469 - # . 1470 - # .SS "8\. How do I install, update, list or remove plugins?" 1471 - # See \fIUsage\fR\. 1472 - # . 1473 - # .SS "9\. How do I upgrade from ___?" 1474 - # You don\'t have to\. fin is framework agnostic and does not interfere with other known systems\. If you want to uninstall oh my fish or fisherman, refer to their documentation\. 1475 - # . 1476 - # .SS "10\. How do I update fin to the latest version?" 1477 - # Run 1478 - # . 1479 - # .IP "" 4 1480 - # . 1481 - # .nf 1482 - # 1483 - # fin update 1484 - # . 1485 - # .fi 1486 - # . 1487 - # .IP "" 0 1488 - # . 1489 - # .SS "12\. What is a plugin?" 1490 - # A plugin is: 1491 - # . 1492 - # .IP "1." 4 1493 - # a directory or git repo with a function \fB\.fish\fR file either at the root level of the project or inside a \fBfunctions\fR directory 1494 - # . 1495 - # .IP "2." 4 1496 - # a theme or prompt, i\.e, a \fBfish_prompt\.fish\fR, \fBfish_right_prompt\.fish\fR or both files 1497 - # . 1498 - # .IP "3." 4 1499 - # a snippet, i\.e, one or more \fB\.fish\fR files inside a directory named \fBconf\.d\fR that are evaluated by fish at the start of the shell 1500 - # . 1501 - # .IP "" 0 1502 - # . 1503 - # .SS "13\. How can I list plugins as dependencies to my plugin?" 1504 - # Create a new \fBbundle\fR file at the root level of your project and write in the plugin dependencies: 1505 - # . 1506 - # .IP "" 4 1507 - # . 1508 - # .nf 1509 - # 1510 - # owner/repo 1511 - # https://github\.com/dude/sweet 1512 - # https://gist\.github\.com/bucaran/c256586044fea832e62f02bc6f6daf32 1513 - # . 1514 - # .fi 1515 - # . 1516 - # .IP "" 0 1517 - # . 1518 - # .SS "14\. I have a question or request not addressed here\. Where should I put it?" 1519 - # Create a new ticket on the issue tracker: 1520 - # . 1521 - # .IP "\(bu" 4 1522 - # https://github\.com/fishery/fin/issues 1523 - # . 1524 - # .IP "" 0 1525 - # . 1526 - # .SS "15\. Why did you create a new project instead of improving fisherman?" 1527 - # . 1528 - # .IP "1." 4 1529 - # fisherman uses an index file and has built\-in search capabilities / advanced completions that are not compatible with fin\'s simpler model 1530 - # . 1531 - # .IP "2." 4 1532 - # I wanted a clean slate and a chance to experiment with something different 1533 - # . 1534 - # .IP "3." 4 1535 - # fin is more opinionated and pragmatic than fisherman, thus truer to fish configurability principle 1536 - # . 1537 - # .IP "" 0 1538 - # . 1539 - # .SS "16\. What about chips and fundle?" 1540 - # chips is far from ready and it\'s not written in fish either\. fundle inspired me to use a bundle and one\-file distribution, but it has limited capabilities and still requires you to edit your fish configuration\. 1541 - # . 1542 - # .SS "17\. Does this mean you are done with fisherman?" 1543 - # Nope\. 1544 - # . 1545 - # .SH "BUGS" 1546 - # When you find issues, please report them: 1547 - # . 1548 - # .IP "\(bu" 4 1549 - # \fIhttp://github\.com/fishery/fin/issues\fR 1550 - # . 1551 - # .IP "" 0 1552 - # . 1553 - # .P 1554 - # Be sure to include all of the output from fin that didn\'t work as expected\. 1555 - # . 1556 - # .SH "AUTHOR" 1557 - # Fisherman was created by Jorge Bucaran :: @bucaran :: j@bucaran\.me 1558 - # . 1559 - # .P 1560 - # See the contributor graph for a list of other people who have contributed to this project: 1561 - # . 1562 - # .IP "\(bu" 4 1563 - # \fIhttps://github\.com/fishery/fin/graphs/contributors\fR 1564 - # . 1565 - # .IP "" 0 1566 - end 1567 - 1568 - 1569 - function __fin_self_destroy 1570 - if test -z "$fish_config" -o -z "$fin_cache" -o -z "$fin_config" -o -L "$fin_cache" -o -L "$fin_config" 1571 - __fin_log error " 1572 - 1573 - Some of fin variables refer to symbolic links or were undefined. 1574 - 1575 - If you are running a custom fin setup, remove the following 1576 - directories and files by yourself: 1577 - 1578 - @$fin_cache@ 1579 - @$fin_config@ 1580 - @$fish_config/functions/fin.fish@ 1581 - @$fish_config/completions/fin.fish@ 1582 - 1583 - " /dev/stderr 1584 - 1585 - __fin_log_error_footer /dev/stderr 1586 - 1587 - return 1 1588 - end 1589 - 1590 - set -l u (set_color -u) 1591 - set -l nc (set_color normal) 1592 - 1593 - switch "$argv" 1594 - case -y --yes 1595 - case \* 1596 - __fin_log warn " 1597 - This will permanently remove fin from your system. 1598 - The following directories and files will be erased: 1599 - 1600 - @$fin_cache@ 1601 - @$fin_config@ 1602 - @$fish_config/functions/fin.fish@ 1603 - @$fish_config/completions/fin.fish@ 1604 - 1605 - " /dev/stderr 1606 - 1607 - echo -sn "Do you wish to continue? [Y/n] " > /dev/stderr 1608 - 1609 - __fin_get_key | read -l yn 1610 - 1611 - switch "$yn" 1612 - case n N 1613 - set -l username 1614 - 1615 - if test ! -z "$USER" 1616 - set username " $USER" 1617 - end 1618 - 1619 - __fin_log okay "As you wish cap!" 1620 - return 1 1621 - end 1622 - end 1623 - 1624 - complete -c fin --erase 1625 - 1626 - __fin_show_spinner 1627 - 1628 - fin ls | fin rm 1629 - 1630 - __fin_show_spinner 1631 - 1632 - command rm -rf "$fin_cache" "$fin_config" 1633 - command rm -f "$fish_config/functions/fin.fish" "$fish_config/completions/fin.fish" 1634 - 1635 - __fin_show_spinner 1636 - 1637 - set -e fin_active_prompt 1638 - set -e fin_cache 1639 - set -e fin_config 1640 - set -e fish_config 1641 - set -e fin_bundle 1642 - set -e fin_version 1643 - set -e fin_spinners 1644 - 1645 - for func in __fin_jobs_await __fin_plugin_url_clone_async __fin_completions_write __fin_plugin_fetch_items __fin_get_epoch_in_ms __fin_jobs_get __fin_get_key __fin_get_plugin_name_from_gist __fin_plugin_get_names __fin_plugin_get_url_info __fin_plugin_get_missing __fin_help __fin_humanize_duration __fin_install __fin_list __fin_list_plugin_directory __fin_log_error_footer __fin_man_page_write __fin_plugin_normalize_path __fin_parse_column_output __fin_parse_comments_from_function __fin_plugin_is_prompt __fin_plugin_disable __fin_plugin_enable __fin_plugin_is_installed __fin_read_bundle_file __fin_reset_default_fish_colors __fin_self_destroy __fin_self_update __fin_usage __fin_update __fin_update_path_async 1646 - __fin_show_spinner 1647 - functions -e "$func" 1648 - end 1649 - 1650 - __fin_show_spinner 1651 - 1652 - functions -e __fin_show_spinner 1653 - 1654 - __fin_log says " 1655 - 1656 - Thanks for trying out fin. If you have a moment, 1657 - please share your feedback in our issue tracker. 1658 - 1659 - @https://github.com/fishery/fin/issues@ 1660 - 1661 - " $__fin_stderr 1662 - 1663 - functions -e __fin_log 1664 - end 1665 - 1666 - 1667 - function fin 1668 - set -g fin_spinners ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ 1669 - 1670 - function __fin_show_spinner 1671 - if not set -q __fin_fg_spinner[1] 1672 - set -g __fin_fg_spinner $fin_spinners 1673 - end 1674 - 1675 - printf " $__fin_fg_spinner[1]\r" > /dev/stderr 1676 - 1677 - set -e __fin_fg_spinner[1] 1678 - end 1679 - 1680 - set -l config_home $XDG_CONFIG_HOME 1681 - set -l cache_home $XDG_CACHE_HOME 1682 - 1683 - if test -z "$config_home" 1684 - set config_home ~/.config 1685 - end 1686 - 1687 - if test -z "$cache_home" 1688 - set cache_home ~/.cache 1689 - end 1690 - 1691 - if test -z "$fish_config" 1692 - set -g fish_config "$config_home/fish" 1693 - end 1694 - 1695 - if test -z "$fin_config" 1696 - set -g fin_config "$config_home/fin" 1697 - end 1698 - 1699 - if test -z "$fin_cache" 1700 - set -g fin_cache "$cache_home/fin" 1701 - end 1702 - 1703 - if test -z "$fin_bundle" 1704 - set -g fin_bundle "$fish_config/bundle" 1705 - end 1706 - 1707 - if not command mkdir -p "$fish_config/"{conf.d,functions,completions} "$fin_config" "$fin_cache" 1708 - __fin_log error " 1709 - I couldn't create the fin configuration. 1710 - You need write permissions in these directories: 1711 - 1712 - @$fish_config@ 1713 - @$fin_config@ 1714 - @$fin_cache@ 1715 - " > /dev/stderr 1716 - 1717 - return 1 1718 - end 1719 - 1720 - set -l elapsed (__fin_get_epoch_in_ms) 1721 - 1722 - set -g __fin_stdout /dev/stdout 1723 - set -g __fin_stderr /dev/stderr 1724 - 1725 - set -l command 1726 - 1727 - for flag in -q --quiet 1728 - if set -l index (builtin contains --index -- $flag $argv) 1729 - set -e argv[$index] 1730 - set __fin_stdout /dev/null 1731 - set __fin_stderr /dev/null 1732 - 1733 - break 1734 - end 1735 - end 1736 - 1737 - switch "$argv[1]" 1738 - case i install 1739 - set -e argv[1] 1740 - set command "install" 1741 - 1742 - case u up update 1743 - set -e argv[1] 1744 - set command "update" 1745 - 1746 - case r rm remove uninstall 1747 - set -e argv[1] 1748 - set command "rm" 1749 - 1750 - case l ls list 1751 - set -e argv[1] 1752 - set command "ls" 1753 - 1754 - case h help 1755 - set -e argv[1] 1756 - __fin_help $argv 1757 - return 1758 - 1759 - case -h 1760 - __fin_usage > /dev/stderr 1761 - return 1762 - 1763 - case --help 1764 - __fin_help 1765 - return 1766 - 1767 - case -v --version 1768 - set -l home ~ 1769 - printf "fin v$fin_version %s\n" (__fin_plugin_normalize_path (status -f) | command awk -v home="$home" '{ sub(home, "~") } //') 1770 - return 1771 - 1772 - case -- "" 1773 - set -e argv[1] 1774 - 1775 - if test -z "$argv" 1776 - set command "default" 1777 - else 1778 - set command "install" 1779 - end 1780 - 1781 - case self-destroy 1782 - set -e argv[1] 1783 - __fin_self_destroy $argv 1784 - return 1785 - 1786 - case -\*\? 1787 - printf "fin: '%s' is not a valid option\n" "$argv[1]" > /dev/stderr 1788 - __fin_usage > /dev/stderr 1789 - return 1 1790 - 1791 - case \* 1792 - set command "install" 1793 - end 1794 - 1795 - set -l items ( 1796 - printf "%s\n" $argv | command awk ' 1797 - 1798 - /^(--|-).*/ { next } 1799 - 1800 - /^omf\// { 1801 - sub(/^omf\//, "oh-my-fish/") 1802 - 1803 - if ($0 !~ /(theme|plugin)-/) { 1804 - sub(/^oh-my-fish\//, "oh-my-fish/plugin-") 1805 - } 1806 - } 1807 - 1808 - !seen[$0]++ 1809 - 1810 - ' 1811 - ) 1812 - 1813 - if test -z "$items" -a "$command" = "default" 1814 - if isatty 1815 - touch "$fin_bundle" 1816 - set items (__fin_read_bundle_file < "$fin_bundle") 1817 - set command "install" 1818 - 1819 - if test -z "$items" 1820 - __fin_log warn " 1821 - The bundle file is empty. 1822 - @$fish_config/bundle@ 1823 - " $__fin_stderr 1824 - 1825 - __fin_log says " 1826 - 1827 - Your bundle keeps track of what's currently installed. 1828 - Write in the plugins you want and run fin again to 1829 - satisfy changes. 1830 - 1831 - You can also install plugins using @fin plugin1 ...@ 1832 - " $__fin_stderr 1833 - 1834 - return 1 1835 - end 1836 - end 1837 - end 1838 - 1839 - switch "$command" 1840 - case install 1841 - if __fin_install $items 1842 - __fin_log says "Done in "(__fin_get_epoch_in_ms $elapsed | __fin_humanize_duration) $__fin_stderr 1843 - end 1844 - 1845 - case update 1846 - if isatty 1847 - if test -z "$items" 1848 - __fin_self_update 1849 - 1850 - set items (__fin_list | command sed 's/^[@* ]*//') 1851 - end 1852 - else 1853 - __fin_parse_column_output | __fin_read_bundle_file | read -laz _items 1854 - set items $items $_items 1855 - end 1856 - 1857 - __fin_update $items 1858 - 1859 - __fin_log says "Done in "(__fin_get_epoch_in_ms $elapsed | __fin_humanize_duration) $__fin_stderr 1860 - 1861 - case ls 1862 - if test "$argv" -ge 0 -o "$argv" = - 1863 - set items (__fin_list) 1864 - 1865 - set -l count (count $items) 1866 - 1867 - if test "$count" -ge 10 1868 - printf "%s\n" $items | column -c$argv 1869 - 1870 - else if test "$count" -ge 1 1871 - printf "%s\n" $items 1872 - end 1873 - 1874 - else 1875 - __fin_list_plugin_directory $argv 1876 - end 1877 - 1878 - case rm 1879 - if test -z "$items" 1880 - __fin_parse_column_output | __fin_read_bundle_file | read -az items 1881 - end 1882 - 1883 - if test (count $items) -le 1 1884 - function __fin_show_spinner 1885 - end 1886 - end 1887 - 1888 - if test ! -z "$items" 1889 - for i in $items 1890 - set -l name (__fin_plugin_get_names "$i")[1] 1891 - __fin_plugin_disable "$fin_config/$name" 1892 - __fin_show_spinner 1893 - end 1894 - end 1895 - 1896 - __fin_log says "Done in "(__fin_get_epoch_in_ms $elapsed | __fin_humanize_duration) $__fin_stderr 1897 - end 1898 - 1899 - complete -c fin --erase 1900 - 1901 - set -l config $fin_config/* 1902 - set -l cache $fin_cache/* 1903 - 1904 - if test -z "$config" 1905 - echo > $fin_bundle 1906 - else 1907 - __fin_plugin_get_url_info -- $config > $fin_bundle 1908 - 1909 - complete -xc fin -n "__fish_seen_subcommand_from u up update r rm remove uninstall" -a "(printf '%s\n' $config | command sed 's|.*/||')" 1910 - complete -xc fin -n "__fish_seen_subcommand_from u up update r rm remove uninstall" -a "$fin_active_prompt" -d "Prompt" 1911 - end 1912 - 1913 - if test ! -z "$cache" 1914 - printf "%s\n" $cache | command awk -v _config="$config" ' 1915 - 1916 - BEGIN { 1917 - count = split(_config, config, " ") 1918 - } 1919 - 1920 - { 1921 - sub(/.*\//, "") 1922 - 1923 - for (i = 1; i <= count; i++) { 1924 - sub(/.*\//, "", config[i]) 1925 - 1926 - if (config[i] == $0) { 1927 - next 1928 - } 1929 - } 1930 - } 1931 - 1932 - // 1933 - 1934 - ' | while read -l plugin 1935 - if __fin_plugin_is_prompt "$fin_cache/$plugin" 1936 - complete -xc fin -n "__fish_seen_subcommand_from i in install" -a "$plugin" -d "Prompt" 1937 - complete -xc fin -n "not __fish_seen_subcommand_from u up update r rm remove uninstall l ls list h help" -a "$plugin" -d "Prompt" 1938 - else 1939 - complete -xc fin -n "__fish_seen_subcommand_from i in install" -a "$plugin" -d "Plugin" 1940 - complete -xc fin -n "not __fish_seen_subcommand_from u up update r rm remove uninstall l ls list h help" -a "$plugin" -d "Plugin" 1941 - end 1942 - end 1943 - end 1944 - 1945 - set -l completions "$fish_config/completions/fin.fish" 1946 - 1947 - if test ! -e "$completions" 1948 - __fin_completions_write > "$completions" 1949 - source "$completions" 1950 - end 1951 - end