mirror of
https://github.com/jorgebucaran/fisher
synced 2024-09-10 15:07:40 +02:00
* Improved README, added links to screencasts, updated documentation with new changes and fixed other typos and composition errors. * Removed `fisher update --cache` in favor of `fisher --cache | fisher update` and `fisher uninstall --all` in favor of `fisher --cache | fisher uninstall`. * Fisherman does not move initialization / configuration files following the convention `name`.config.fish to `$fisher_config/functions`, but to `$fisher_config/conf.d` now and evaluates each `*.config.fish` inside at shell start as usual. Closes #13. * Added `fisher --cache[=base]` option to retrieve contents in `$fisher_cache`, eliminating flaky usage of `find(1)`. Closes #11. * Fisherman now generates information about plugins installed via custom URLs. For the description, a shortened version of the URL is used. For the URL the full URL is used. For tags, the URL is fuzzily checked and tags such as _theme_, _plugin_, _config_ and _omf_ are added. The tag _orphan_ is added by default as well. Finally, the author is generated by retrieving the e-mail or username of the author of the first commit in the plugin's repository. Closes #9 and #14. * Changed `--path-in-cache` to `--translate.` This function translates an name or supported URL/URL variation into a path inside `$fisher_cache`. This allows you to treat plugins installed via custom URLs almost like regular plugins if they are installed. Closes #8. * Fixed a bug with `mktemp` failing on some systems. Closes #7. Thanks @tobywf. * Added [CODE_OF_CONDUCT][code_of_conduct]. Closes #6. * Fisherman can now unload themes within the same shell, without having to restart the session. Closes #5. * Fisherman can now load themes within the same shell, without having to restart the session using `exec fish`. Shoddy themes, for example those failing to declare global variables with the `-g` flag still require the session to be reset. See [**related**][bobthefish-19]. Closes #4. * Move `getopts` implementation to `share/getopts.awk`. Closes #3. * Support dots inside URIs in `fisher --validate`. Closes #2.
179 lines
5 KiB
Fish
179 lines
5 KiB
Fish
function fisher -d "Fish plugin manager"
|
|
if not set -q argv[1]
|
|
fisher --help
|
|
return 1
|
|
end
|
|
|
|
set -l option
|
|
set -l value
|
|
set -l quiet -E .
|
|
|
|
getopts $argv | while read -l 1 2
|
|
switch "$1"
|
|
case _
|
|
set option command
|
|
set value $2
|
|
break
|
|
|
|
case h help
|
|
set option help
|
|
set value $value $2
|
|
|
|
case cache
|
|
set option cache
|
|
set value $2
|
|
|
|
case translate
|
|
set option translate
|
|
set value $2
|
|
|
|
case f file
|
|
set option file
|
|
set value $2
|
|
|
|
case V validate
|
|
set option validate
|
|
set value $2
|
|
|
|
case v version
|
|
set option version
|
|
|
|
case q quiet
|
|
set quiet -q .
|
|
|
|
case \*
|
|
printf "fisher: '%s' is not a valid option\n" $1 >& 2
|
|
fisher --help >& 2
|
|
return 1
|
|
end
|
|
end
|
|
|
|
switch "$option"
|
|
case command
|
|
printf "%s\n" $fisher_alias | sed 's/[=,]/ /g' | while read -la alias
|
|
if set -q alias[2]
|
|
switch "$value"
|
|
case $alias[2..-1]
|
|
set value $alias[1]
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
if not functions -q "fisher_$value"
|
|
printf "fisher: '%s' is not a valid command\n" "$value" >& 2
|
|
fisher --help >& 2 | head -n1 >& 2
|
|
return 1
|
|
end
|
|
|
|
set -e argv[1]
|
|
|
|
if not eval "fisher_$value" (printf "%s\n" "'"$argv"'")
|
|
return 1
|
|
end
|
|
|
|
case validate
|
|
if not test -z "$value"
|
|
printf "%s\n" $value | fisher --validate | grep $quiet
|
|
return
|
|
end
|
|
|
|
if not set -q fisher_default_host
|
|
set fisher_default_host https://github.com
|
|
end
|
|
|
|
set -l id "[A-Za-z0-9_.-]"
|
|
|
|
sed -En "
|
|
s#/\$##
|
|
s#\.git\$##
|
|
s#^(https?):*/* *(.*\$)#\1://\2#p
|
|
s#^(@|(gh[:/])|(github(.com)?[/:]))/?($id+)/($id+)\$#https://github.com/\5/\6#p
|
|
s#^(bb[:/])/*($id+)/($id+)\$#https://bitbucket.org/\2/\3#p
|
|
s#^(gl[:/])/*($id+)/($id+)\$#https://gitlab.com/\2/\3#p
|
|
s#^(omf[:/])/*($id+)\$#https://github.com/oh-my-fish/\2#p
|
|
s#^($id+)/($id+)\$#$fisher_default_host/\1/\2#p
|
|
/^file:\/\/\/.*/p
|
|
/^[a-z]+([._-]?[a-z0-9]+)*\$/p
|
|
" | grep $quiet
|
|
|
|
case cache
|
|
for file in $fisher_cache/*
|
|
if test -d $file
|
|
switch "$value"
|
|
case base
|
|
basename $file
|
|
|
|
case \*
|
|
printf "%s\n" $file
|
|
end
|
|
end
|
|
end
|
|
|
|
case translate
|
|
while read --prompt="" -l item
|
|
switch "$item"
|
|
case \*/\*
|
|
for file in $fisher_cache/*
|
|
switch "$item"
|
|
case (git -C $file ls-remote --get-url | fisher --validate)
|
|
printf "%s\n" $file
|
|
break
|
|
end
|
|
end
|
|
|
|
case \*
|
|
printf "%s\n" $fisher_cache/$item
|
|
end
|
|
end
|
|
|
|
case file
|
|
switch "$value"
|
|
case "-"
|
|
set value /dev/stdin
|
|
case ""
|
|
set value $fisher_config/fishfile
|
|
end
|
|
|
|
awk '
|
|
!/^ *(#.*)*$/ {
|
|
gsub("#.*", "")
|
|
|
|
if (/^ *package .+/) {
|
|
$1 = $2
|
|
}
|
|
|
|
if (!k[$1]++) {
|
|
printf("%s\n", $1)
|
|
}
|
|
}
|
|
' $value
|
|
|
|
case version
|
|
sed 's/^/fisher version /;q' $fisher_home/VERSION
|
|
|
|
case help
|
|
if test -z "$value"
|
|
set value commands
|
|
end
|
|
|
|
printf "usage: fisher <command> [<options>] [--version] [--help]\n\n"
|
|
|
|
switch commands
|
|
case $value
|
|
printf "Available Fisherman commands:\n"
|
|
fisher_help --commands=bare
|
|
echo
|
|
end
|
|
|
|
switch guides
|
|
case $value
|
|
printf "Available Fisherman guides:\n"
|
|
fisher_help --guides=bare
|
|
echo
|
|
end
|
|
|
|
printf "Use 'fisher help -g' to list guides and other documentation.\n"
|
|
printf "See 'fisher help <command or concept>' to access a man page.\n"
|
|
end
|
|
end
|