mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-26 10:13:46 +08:00
Merge all omf list functions
This commit is contained in:
parent
dc8ec2ec1d
commit
870efd0dda
|
@ -2,8 +2,8 @@ function omf.bundle.install
|
||||||
set bundle $OMF_CONFIG/bundle
|
set bundle $OMF_CONFIG/bundle
|
||||||
|
|
||||||
if test -f $bundle
|
if test -f $bundle
|
||||||
set packages (omf.list_local_packages)
|
set packages (omf.packages.list --installed --plugin)
|
||||||
set themes (omf.list_installed_themes)
|
set themes (omf.packages.list --installed --theme)
|
||||||
set bundle_contents (cat $bundle | sort -u)
|
set bundle_contents (cat $bundle | sort -u)
|
||||||
|
|
||||||
for record in $bundle_contents
|
for record in $bundle_contents
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
function omf.describe -a name
|
function omf.describe -a name
|
||||||
if test (count $argv) -eq 0
|
if test (count $argv) -eq 0
|
||||||
for package in (omf.list_db_packages)
|
for package in (omf.packages.list --database)
|
||||||
echo $package - (omf.describe $package)
|
echo $package - (omf.describe $package)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
set package_path $OMF_PATH/db/pkg/$name
|
set package_path $OMF_PATH/db/pkg/$name
|
||||||
|
|
||||||
if test -e $package_path
|
if test -e $package_path
|
||||||
set url (cat $package_path)
|
set url (cat $package_path)
|
||||||
set repo (basename (dirname $url))/(basename $url)
|
set repo (basename (dirname $url))/(basename $url)
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# List all packages available to install from the registry.
|
|
||||||
function omf.list_db_packages -a skip_installed
|
|
||||||
for item in (basename $OMF_PATH/db/pkg/*)
|
|
||||||
if begin
|
|
||||||
test -z $skip_installed
|
|
||||||
or not contains $item (basename {$OMF_PATH,$OMF_CONFIG}/pkg/*)
|
|
||||||
end
|
|
||||||
echo $item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
# List all packages installed from the registry.
|
|
||||||
function omf.list_installed_packages
|
|
||||||
for item in (basename $OMF_PATH/pkg/*)
|
|
||||||
test $item = omf; or echo $item
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
function omf.list_installed_themes
|
|
||||||
basename $OMF_PATH/themes/*
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
# List all custom packages and packages installed from the registry.
|
|
||||||
function omf.list_local_packages
|
|
||||||
for item in (basename {$OMF_PATH,$OMF_CONFIG}/pkg/*)
|
|
||||||
test $item = omf; or echo $item
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
function omf.list_themes
|
|
||||||
set -l seen ""
|
|
||||||
for theme in (basename $OMF_PATH/db/themes/*) \
|
|
||||||
(basename {$OMF_PATH,$OMF_CONFIG}/themes/*)
|
|
||||||
contains $theme $seen; or echo $theme
|
|
||||||
set seen $seen $theme
|
|
||||||
end
|
|
||||||
end
|
|
72
pkg/omf/cli/omf.packages.list.fish
Normal file
72
pkg/omf/cli/omf.packages.list.fish
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
function __omf.packages.sort
|
||||||
|
for package in (echo $argv | tr ' ' '\n' | sort); echo $package; end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __omf.packages.list -a type
|
||||||
|
set -l list
|
||||||
|
|
||||||
|
test "$type" = "--theme"; or for package in (basename {$OMF_CONFIG,$OMF_PATH/db}/pkg/*)
|
||||||
|
set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
test "$type" = "--plugin"; or for package in (basename {$OMF_CONFIG,$OMF_PATH/db}/themes/*)
|
||||||
|
set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
__omf.packages.sort $list
|
||||||
|
end
|
||||||
|
|
||||||
|
function __omf.packages.list.available -a type
|
||||||
|
set -l list
|
||||||
|
|
||||||
|
test "$type" = "--theme"; or for package in (basename $OMF_PATH/db/pkg/*)
|
||||||
|
contains $package (basename {$OMF_CONFIG,$OMF_PATH}/pkg/*); or set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
test "$type" = "--plugin"; or for package in (basename $OMF_PATH/db/themes/*)
|
||||||
|
contains $package (basename {$OMF_CONFIG,$OMF_PATH}/themes/*); or set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
__omf.packages.sort $list
|
||||||
|
end
|
||||||
|
|
||||||
|
function __omf.packages.list.database -a type
|
||||||
|
set -l list
|
||||||
|
|
||||||
|
test "$type" = "--theme"; or for package in (basename $OMF_PATH/db/pkg/*)
|
||||||
|
set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
test "$type" = "--plugin"; or for package in (basename $OMF_PATH/db/themes/*)
|
||||||
|
set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
__omf.packages.sort $list
|
||||||
|
end
|
||||||
|
|
||||||
|
function __omf.packages.list.installed -a type
|
||||||
|
set -l list
|
||||||
|
|
||||||
|
test "$type" = "--theme"; or for package in (basename {$OMF_CONFIG,$OMF_PATH}/pkg/*)
|
||||||
|
set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
test "$type" = "--plugin"; or for package in (basename {$OMF_CONFIG,$OMF_PATH}/themes/*)
|
||||||
|
set list $list $package
|
||||||
|
end
|
||||||
|
|
||||||
|
__omf.packages.sort $list
|
||||||
|
end
|
||||||
|
|
||||||
|
function omf.packages.list -a option type
|
||||||
|
switch "$option"
|
||||||
|
case "--available"
|
||||||
|
__omf.packages.list.available $type
|
||||||
|
case "--database"
|
||||||
|
__omf.packages.list.database $type
|
||||||
|
case "--installed"
|
||||||
|
__omf.packages.list.installed $type
|
||||||
|
case "*"
|
||||||
|
__omf.packages.list $type
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
complete -c omf -f -d "Oh My Fish"
|
complete -c omf -f -d "Oh My Fish"
|
||||||
|
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from r rm remove" -a (printf "%s " (omf.list_local_packages) (omf.list_installed_themes))
|
complete -c omf -f -n "__fish_seen_subcommand_from r rm remove" -a (printf "%s " (omf.packages.list --installed))
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from d desc describe" -a (printf "%s " (omf.list_db_packages))
|
complete -c omf -f -n "__fish_seen_subcommand_from d desc describe" -a (printf "%s " (omf.packages.list --database --plugin))
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from c cd" -a (printf "%s " (omf.list_db_packages))
|
complete -c omf -f -n "__fish_seen_subcommand_from c cd" -a (printf "%s " (omf.packages.list --installed))
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from i install" -a (printf "%s " (omf.list_db_packages "skip installed packages"))
|
complete -c omf -f -n "__fish_seen_subcommand_from i install" -a (printf "%s " (omf.packages.list --available --plugin))
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from t theme" -a (printf "%s " (omf.list_themes))
|
complete -c omf -f -n "__fish_seen_subcommand_from t theme" -a (printf "%s " (omf.packages.list --database --theme))
|
||||||
complete -c omf -f -n "__fish_seen_subcommand_from help" -a "install theme remove update list describe cd new submit destroy doctor"
|
complete -c omf -f -n "__fish_seen_subcommand_from help" -a "install theme remove update list describe cd new submit destroy doctor"
|
||||||
|
|
||||||
complete -c omf -f -a list -n "__fish_use_subcommand" -d "List local packages"
|
complete -c omf -f -a list -n "__fish_use_subcommand" -d "List local packages"
|
||||||
|
|
|
@ -83,7 +83,7 @@ function omf -d "Oh My Fish"
|
||||||
end
|
end
|
||||||
|
|
||||||
case "l" "ls" "list"
|
case "l" "ls" "list"
|
||||||
omf.list_local_packages | column
|
omf.packages.list --installed | column
|
||||||
|
|
||||||
case "n" "new"
|
case "n" "new"
|
||||||
if test (count $argv) -ne 3
|
if test (count $argv) -ne 3
|
||||||
|
@ -118,10 +118,10 @@ function omf -d "Oh My Fish"
|
||||||
set -l regex "[[:<:]]($theme)[[:>:]]"
|
set -l regex "[[:<:]]($theme)[[:>:]]"
|
||||||
test "$ostype" != "Darwin"; and set regex "\b($theme)\b"
|
test "$ostype" != "Darwin"; and set regex "\b($theme)\b"
|
||||||
|
|
||||||
omf.list_themes | column | sed -E "s/$regex/"(omf::em)"\1"(omf::off)"/"
|
omf.packages.list --database --theme | column | sed -E "s/$regex/"(omf::em)"\1"(omf::off)"/"
|
||||||
omf::off
|
omf::off
|
||||||
else if test (count $argv) -eq 2
|
else if test (count $argv) -eq 2
|
||||||
if not contains -- $argv[2] (omf.list_installed_themes)
|
if not contains -- $argv[2] (omf.packages.list --installed)
|
||||||
omf.install --theme $argv[2]; or return 1
|
omf.install --theme $argv[2]; or return 1
|
||||||
end
|
end
|
||||||
omf.theme $argv[2]
|
omf.theme $argv[2]
|
||||||
|
@ -140,7 +140,7 @@ function omf -d "Oh My Fish"
|
||||||
echo "Please open a new issue here → "(omf::em)"github.com/oh-my-fish/oh-my-fish/issues"(omf::off)
|
echo "Please open a new issue here → "(omf::em)"github.com/oh-my-fish/oh-my-fish/issues"(omf::off)
|
||||||
end
|
end
|
||||||
omf.theme (cat $OMF_CONFIG/theme)
|
omf.theme (cat $OMF_CONFIG/theme)
|
||||||
omf.install_package (omf.list_installed_packages)
|
omf.install_package (omf.packages.list --installed --plugin)
|
||||||
refresh
|
refresh
|
||||||
|
|
||||||
case "*"
|
case "*"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user