mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-01-22 13:05:14 +08:00
omf list function
This commit is contained in:
parent
46f0a3f981
commit
2930c81228
|
@ -11,6 +11,8 @@ function omf -d "Oh My Fish helper"
|
||||||
omf.packages --install
|
omf.packages --install
|
||||||
case 'update'
|
case 'update'
|
||||||
omf.packages --update
|
omf.packages --update
|
||||||
|
case 'list' 'ls'
|
||||||
|
omf.packages --list
|
||||||
case '*'
|
case '*'
|
||||||
omf.helper
|
omf.helper
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,5 +11,6 @@ function omf.helper -d 'Prints all functions supported by Oh My Fish helper'
|
||||||
omf.log normal ' Examples:'
|
omf.log normal ' Examples:'
|
||||||
omf.log normal ' omf install'
|
omf.log normal ' omf install'
|
||||||
omf.log normal ' omf update'
|
omf.log normal ' omf update'
|
||||||
|
omf.log normal ' omf list'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,20 +9,54 @@
|
||||||
# Install all packages
|
# Install all packages
|
||||||
# --update
|
# --update
|
||||||
# Update all packages
|
# Update all packages
|
||||||
|
# --list
|
||||||
|
# List all active packages
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Manage all plugins and themes specified on the $fish_plugins
|
# Manage all plugins and themes specified on the $fish_plugins
|
||||||
# and $fish_theme variables
|
# and $fish_theme variables
|
||||||
#
|
#
|
||||||
function omf.packages --argument-names options -d 'Manage all plugins and themes'
|
function omf.packages --argument-names options -d 'Manage all plugins and themes'
|
||||||
set -l modified_packages 0
|
set -g __omf_packages_modified 0
|
||||||
|
|
||||||
switch $options
|
switch $options
|
||||||
case "--install"
|
case '--install'
|
||||||
omf.packages.install
|
for plugin in $fish_plugins
|
||||||
case "--update"
|
omf.packages.install --plugin $plugin
|
||||||
omf.packages.update
|
end
|
||||||
case "*"
|
|
||||||
|
omf.packages.install --theme $fish_theme
|
||||||
|
|
||||||
|
if [ $__omf_packages_modified -eq 0 ]
|
||||||
|
omf.log green 'All packages were already installed.'
|
||||||
|
end
|
||||||
|
case '--update'
|
||||||
|
for plugin in $fish_plugins
|
||||||
|
omf.packages.update --plugin $plugin
|
||||||
|
end
|
||||||
|
|
||||||
|
omf.packages.update --theme $fish_theme
|
||||||
|
|
||||||
|
if [ $__omf_packages_modified -eq 0 ]
|
||||||
|
omf.log green 'All packages were already updated'
|
||||||
|
end
|
||||||
|
case '--list'
|
||||||
|
omf.log yellow 'Plugins: '
|
||||||
|
omf.log normal $fish_plugins
|
||||||
|
|
||||||
|
omf.log normal ''
|
||||||
|
omf.log yellow 'Theme: '
|
||||||
|
omf.log normal $fish_theme
|
||||||
|
case '*'
|
||||||
omf.log red 'Unknown option'
|
omf.log red 'Unknown option'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function omf.packages.report.started -e omf_package_installing -e omf_package_updating
|
||||||
|
omf.log -n white "Installing $argv... "
|
||||||
|
end
|
||||||
|
|
||||||
|
function omf.packages.report.finished -e omf_package_installed -e omf_package_updated
|
||||||
|
omf.log green "√"
|
||||||
|
set __omf_packages_modified (expr $__omf_packages_modified + 1)
|
||||||
|
end
|
||||||
|
|
|
@ -1,36 +1,32 @@
|
||||||
# NAME
|
# NAME
|
||||||
# omf.packages.install - Install all plugins and themes
|
# omf.packages.install - Install a plugin or theme
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
# --plugin <plugin_name>
|
||||||
|
# --theme <theme_name>
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Install all plugins and themes specified on the $fish_plugins
|
# Install a plugin or theme
|
||||||
# and $fish_theme variables
|
|
||||||
#
|
#
|
||||||
function omf.packages.install -d "Install all plugins and themes"
|
function omf.packages.install --argument-names type name -d "Install a plugin or theme"
|
||||||
set -l installed_packages 0
|
switch $type
|
||||||
|
case '--plugin'
|
||||||
# Plugins
|
if [ -e $fish_path/plugins/$name -o -e $fish_custom/plugins/$name ]
|
||||||
for plugin in $fish_plugins
|
#echo "$plugin is already installed. Skipping."
|
||||||
if [ -e $fish_path/plugins/$plugin -o -e $fish_custom/plugins/$plugin ]
|
else
|
||||||
#echo "$plugin is already installed. Skipping."
|
emit omf_package_installing $name
|
||||||
else
|
git clone "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name ^ /dev/null
|
||||||
omf.log -n white "Installing $plugin... "
|
emit omf_package_installed $name
|
||||||
git clone "https://github.com/oh-my-fish/plugins-$plugin" $fish_path/plugins/$plugin ^ /dev/null
|
end
|
||||||
omf.log green "√"
|
case '--theme'
|
||||||
set -l installed_packages 1
|
if [ -e $fish_path/themes/$name -o -e $fish_custom/themes/$name ]
|
||||||
end
|
#echo "$fish_theme is already installed. Skipping."
|
||||||
end
|
else
|
||||||
|
emit omf_package_installing $name
|
||||||
# Theme
|
git clone "https://github.com/oh-my-fish/theme-$name" $fish_path/themes/$name ^ /dev/null
|
||||||
if [ -e $fish_path/themes/$fish_theme -o -e $fish_custom/themes/$fish_theme ]
|
emit omf_package_installed $name
|
||||||
#echo "$fish_theme is already installed. Skipping."
|
end
|
||||||
else
|
case '*'
|
||||||
omf.log -n white "Installing $fish_theme... "
|
omf.log red 'Unknown option'
|
||||||
git clone "https://github.com/oh-my-fish/themes-$fish_theme" $fish_path/themes/$fish_theme ^ /dev/null
|
|
||||||
omf.log green "√"
|
|
||||||
set -l installed_packages 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if [ $installed_packages -eq 0 ]
|
|
||||||
omf.log green 'All plugins were already installed.'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,53 +1,52 @@
|
||||||
# NAME
|
# NAME
|
||||||
# omf.packages.update - Update all plugins and themes
|
# omf.packages.update - Update a plugin or theme
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
# --plugin <plugin_name>
|
||||||
|
# --theme <theme_name>
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Update all plugins and themes specified on the $fish_plugins
|
# Update a plugin or theme
|
||||||
# and $fish_theme variables
|
|
||||||
#
|
#
|
||||||
function omf.packages.update -d "Update all plugins and themes"
|
function omf.packages.update --argument-names type name -d "Update a plugin or theme"
|
||||||
set -l installed_packages 0
|
pushd # Save current dir
|
||||||
pushd
|
|
||||||
|
|
||||||
# Plugins
|
switch $type
|
||||||
for plugin in $fish_plugins
|
case '--plugin'
|
||||||
if [ -e $fish_path/plugins/$plugin -a -e $fish_path/plugins/$plugin/.git ]
|
if [ -e $fish_path/plugins/$name -a -e $fish_path/plugins/$name/.git ]
|
||||||
omf.log -n white "Updating $plugin... "
|
omf.log -n white "Updating $name "
|
||||||
echo (cd $fish_path/plugins/$plugin; and git pull --rebase > /dev/null) >/dev/null
|
echo (cd $fish_path/plugins/$name; and git pull --rebase > /dev/null) >/dev/null
|
||||||
omf.log green "√"
|
|
||||||
set -l installed_packages 1
|
|
||||||
else
|
|
||||||
if [ -e $fish_custom/plugins/$plugin -a -e $fish_custom/plugins/$plugin/.git ]
|
|
||||||
omf.log -n white "Updating $plugin... "
|
|
||||||
echo (cd $fish_custom/plugins/$plugin; and git pull --rebase > /dev/null) >/dev/null
|
|
||||||
omf.log green "√"
|
omf.log green "√"
|
||||||
set -l installed_packages 1
|
emit omf_package_updated
|
||||||
else
|
else
|
||||||
#echo "$plugin is not installed or not a git repo. Skipping."
|
if [ -e $fish_custom/plugins/$name -a -e $fish_custom/plugins/$name/.git ]
|
||||||
|
omf.log -n white "Updating $name "
|
||||||
|
echo (cd $fish_custom/plugins/$name; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
omf.log green "√"
|
||||||
|
emit omf_package_updated
|
||||||
|
else
|
||||||
|
#echo "Plugin is not installed or not a git repo. Skipping."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
case '--theme'
|
||||||
|
if [ -e $fish_path/themes/$name -a -e $fish_path/themes/$name/.git ]
|
||||||
|
omf.log -n white "Updating $name "
|
||||||
|
echo (cd $fish_path/themes/$name; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
omf.log green "√"
|
||||||
|
emit omf_package_updated
|
||||||
|
else
|
||||||
|
if [ -e $fish_custom/themes/$name -a -e $fish_custom/themes/$name/.git ]
|
||||||
|
omf.log -n white "Updating $name "
|
||||||
|
echo (cd $fish_custom/themes/$name; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
omf.log green "√"
|
||||||
|
emit omf_package_updated
|
||||||
|
else
|
||||||
|
#echo "Theme is not installed or not a git repo. Skipping."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
case '*'
|
||||||
|
omf.log red 'Unknown option'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Theme
|
popd # Restore current dir
|
||||||
if [ -e $fish_path/themes/$fish_theme -a -e $fish_path/themes/$fish_theme/.git ]
|
|
||||||
omf.log -n white "Updating $fish_theme... "
|
|
||||||
echo (cd $fish_path/themes/$fish_theme; and git pull --rebase > /dev/null) >/dev/null
|
|
||||||
omf.log green "√"
|
|
||||||
set -l installed_packages 1
|
|
||||||
else
|
|
||||||
if [ -e $fish_custom/themes/$fish_theme -a -e $fish_custom/themes/$fish_theme/.git ]
|
|
||||||
omf.log -n white "Updating $fish_theme... "
|
|
||||||
echo (cd $fish_custom/themes/$fish_theme; and git pull --rebase > /dev/null) >/dev/null
|
|
||||||
omf.log green "√"
|
|
||||||
set -l installed_packages 1
|
|
||||||
else
|
|
||||||
#echo "$fish_theme is not installed or not a git repo. Skipping."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if [ $installed_packages -eq 0 ]
|
|
||||||
omf.log green 'No plugins to update.'
|
|
||||||
end
|
|
||||||
|
|
||||||
popd
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user