fisher/functions/fisher_uninstall.fish

124 lines
3.3 KiB
Fish
Raw Normal View History

function fisher_uninstall -d "Disable / Uninstall Plugins"
set -l option
set -l items
set -l error /dev/stderr
getopts $argv | while read -l 1 2
switch "$1"
case _
set items $items $2
case a all
set option $option all
case f force
set option $option force
case q quiet
set error /dev/null
case help h
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
printf "usage: fisher uninstall [<name or url> ...] [--force] [--quiet] [--help]\n\n"
printf " -f --force Delete copy from cache \n"
printf " -q --quiet Enable quiet mode \n"
printf " -h --help Show usage help \n"
return
case \*
printf "fisher: '%s' is not a valid option\n" $1 >& 2
fisher_uninstall --help >& 2
return 1
end
end
set -l count 0
set -l duration (date +%s)
set -l total (count $items)
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
if set -q items[1]
printf "%s\n" $items
else
fisher --file=-
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
end | fisher --validate | fisher --translate | while read -l path
if not test -d "$path"
printf "fisher: '%s' not found\n" $path > $error
continue
end
set -l name (basename $path)
printf "Uninstalling " > $error
switch $total
case 0 1
printf ">> %s\n" $name > $error
case \*
printf "(%s of %s) >> %s\n" (math 1 + $count) $total $name > $error
end
set count (math $count + 1)
for file in $path/{*,functions{/*,/**/*}}.fish
set -l base (basename $file)
switch $base
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
case {$name,fish_{,right_}prompt}.fish
functions -e (basename $base .fish)
if test "$base" = fish_prompt.fish
source $__fish_datadir/functions/fish_prompt.fish ^ /dev/null
end
case {init,before.init,uninstall}.fish
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
set base $name.(basename $base .fish).config.fish
end
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
rm -f $file $fisher_config/{functions,conf.d}/$base
end
for file in $path/completions/*.fish
rm -f $fisher_config/completions/(basename $file)
end
for n in (seq 9)
if test -d $path/man/man$n
for file in $path/man/man$n/*.$n
rm -f $fisher_config/man/man$n/(basename $file)
end
end
end
git -C $path ls-remote --get-url ^ /dev/null | fisher --validate | read -l url
switch force
case $option
rm -rf $path
end
set -l file $fisher_config/fishfile
if not fisher --file=$file | grep -Eq "^$name\$|^$url\$"
continue
end
Fisherman v0.2.0 * 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.
2016-01-03 04:35:56 +01:00
set -l tmp (mktemp -t fisher.XXX)
if not sed -E '/^ *'(printf "%s|%s" $name $url | sed 's|/|\\\/|g'
)'([ #].*)*$/d' < $file > $tmp
rm -f $tmp
printf "fisher: can't delete '%s' from %s\n" $name $file > $error
return 1
end
mv -f $tmp $file
end
printf "%d plugin/s uninstalled (%0.fs)\n" $count (math (date +%s) - $duration) > $error
test $count -gt 0
end