fisher/functions/wait.fish
Jorge Bucaran ab43e5f804
Introducting Fisherman's official website:
www.fisherman.sh

Still a WIP. Powered by Jekyll and hosted by GitHub
pages.

* Refactor fisher install / fisher uninstall by
extracting the logic to enable / disable plugins
into __fisher_plugin. The algorithm to enable/disable
plugins is essentially the same. The only difference
is enable, copies/symlinks files and disable removes
them from $fisher_config/.... Closes #45.

* Add support for legacy oh-my-fish! plugins using
.load initialization files. Closes #35.

* Add support for Tackle Fish framework initialization
modules. Closes #35.

* Add support for plugins that share scripts in
languages like Python or Perl. For example
oh-my-fish/plugin-vi-mode assumes there is a
vi-mode-impl.py file in the same path of the running
script. This opens the door for including code
snippets in other languages.

* Any files inside a share directory, except for *.md
or *.fish files, are copied to $fisher_config/functions.
This allows you to run legacy plugins that retrieve
the currently running script path with (dirname
(status -f)) out of the box.

* A cleaner alternative is using the new $fisher_share
variable like this: python
$fisher_share/my_plugin_script.py.

* $fisher_share points to $fisher_config/share by
default, but you may change this in your user
config.fish. This path contains copies (or symbolic
links) to the same script files copied to
$fisher_config/functions.

* Introduce the $fisher_share_extensions variable to
let you customize what extensions Fisherman is aware
of. Only extensions in this array will be processed
during the install process. The default is py rb php
pl awk sed.

* .fish and .md extensions are always ignored.

* Remove ad-hoc debug d function created by mistake
in the Fisherman config.fish file. Closes #34.

* Remove almost useless fisher --alias. You can still
create aliases using $fisher_alias. It's difficult
to add auto-complete to this feature, and even if
we do so, it is slow.

* Fix bug introduced in the previous release caused
by swapping the lines that calculate the index of
the current plugin being installed/updated/uninstalled
and the line that displays the value, causing the
CLI to show incorrect values. Closes #36. Thanks
@kballard

* Add cache, enabled and disabled options to fisher
--list. Now you can type fisher -l enabled to get a
list of what plugins are currently enabled.

* Add new $fisher_plugins universal variable to keep
track of what plugins are enabled / disabled.

* Update completions after a plugin is installed,
updated or uninstalled.

* Improve autocomplete speed by removing the descriptions
from plugins installed with custom URLs.

* fisher --list displays nothing and returns 1 when
there are no plugins installed. Closes #38.

* fisher uninstall does not attempt to uninstall plugins
already disabled by looking at the $fisher_plugins
array. --force will bypass this. Closes #40
2016-01-12 05:00:34 +09:00

142 lines
3.7 KiB
Fish
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function wait -d "Run commands and wait with a spin"
set -l option
set -l commands
set -l spinners
set -l time 0.02
set -l log
set -l format "@\r"
getopts $argv | while read -l 1 2
switch "$1"
case -
case _
set commands $commands ";$2"
case s spin spinner{,s} style
set spinners $spinners $2
case t time
set time $2
case l log
set log $2
case f format
set format $2
case help
set option help
case h
printf "usage: wait <commands> [--spin=<style>] [--time=<delay>] [--log=<file>] \n"
printf " [--format=<format>] [--help]\n\n"
printf " -s --spin=<style> Set spinner style\n"
printf " -t --time=<delay> Set spinner transition time delay\n"
printf " -l --log=<file> Output standard error to <file>\n"
printf " -f --format=<format> Use given <format> to display spinner\n"
printf " -h --help Show usage help\n"
return
case \*
printf "wait: '%s' is not a valid option\n" $1 >& 2
wait -h >& 2
return 1
end
end
switch "$option"
case help
man wait
return
end
if not set -q commands[1]
return 1
end
switch "$spinners"
case arc star pipe ball flip mixer caret
set -l arc "◜◠◝◞◡◟"
set -l star "+x*"
set -l pipe "-\\|/"
set -l ball "▖▘▝▗"
set -l flip "___-``'´-___"
set -l mixer "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆"
set -l caret "II||"
set spinners "$$spinners"
case bar{1,2,3,\?\?\*}
set -l bar
set -l bar1 "[" "=" " " "]" "%"
set -l bar2 "[" "#" " " "]" "%"
set -l bar3 "." "." " " " " "%"
switch "$spinners"
case \*{1,2,3}
case \*
printf "%s\n" $spinners | sed -E 's/^bar.?//;s/./& /g' | read -az bar
set spinners bar
end
set -l IFS \t
printf "%s\t" $$spinners | read -l open fill void close symbol
set spinners
for i in (seq 5 5 100)
if test -n "$symbol"
set symbol "$i%"
end
set -l gap (printf "$void%.0s" (seq (math 100 - $i)))
if test $i -ge 100
set gap ""
end
set spinners $spinners "$open"(printf "$fill%.0s" (seq $i))"$gap$close $symbol"
end
end
set -l tmp (mktemp -t wait.XXX)
fish -c "$commands" ^ $tmp &
if not set -q spinners[2]
set spinners (printf "%s\n" "$spinners" | grep -o .)
end
while true
if status --is-interactive
for i in $spinners
printf "$format" | awk -v t=$time -v i=(printf "%s\n" $i | sed 's/=/\\\=/') '
{
system("tput civis")
gsub("@", i)
printf("%s", $0)
system("sleep "t";tput cnorm")
}
' > /dev/stderr
end
end
if test -z (jobs)
printf "$format" | tr @ "\0" > /dev/stderr
break
end
end
if test -s $tmp
if set -q log[1]
nl -n ln -- $tmp > $log
end
rm -f $tmp
return 1
end
rm -f $tmp
end