mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-01-22 09:26: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
|
||||
case 'update'
|
||||
omf.packages --update
|
||||
case 'list' 'ls'
|
||||
omf.packages --list
|
||||
case '*'
|
||||
omf.helper
|
||||
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 ' omf install'
|
||||
omf.log normal ' omf update'
|
||||
omf.log normal ' omf list'
|
||||
end
|
||||
|
||||
|
|
|
@ -9,20 +9,54 @@
|
|||
# Install all packages
|
||||
# --update
|
||||
# Update all packages
|
||||
# --list
|
||||
# List all active packages
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Manage all plugins and themes specified on the $fish_plugins
|
||||
# and $fish_theme variables
|
||||
#
|
||||
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
|
||||
case "--install"
|
||||
omf.packages.install
|
||||
case "--update"
|
||||
omf.packages.update
|
||||
case "*"
|
||||
case '--install'
|
||||
for plugin in $fish_plugins
|
||||
omf.packages.install --plugin $plugin
|
||||
end
|
||||
|
||||
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'
|
||||
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
|
||||
# omf.packages.install - Install all plugins and themes
|
||||
# omf.packages.install - Install a plugin or theme
|
||||
#
|
||||
# SYNOPSIS
|
||||
# --plugin <plugin_name>
|
||||
# --theme <theme_name>
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Install all plugins and themes specified on the $fish_plugins
|
||||
# and $fish_theme variables
|
||||
# Install a plugin or theme
|
||||
#
|
||||
function omf.packages.install -d "Install all plugins and themes"
|
||||
set -l installed_packages 0
|
||||
|
||||
# Plugins
|
||||
for plugin in $fish_plugins
|
||||
if [ -e $fish_path/plugins/$plugin -o -e $fish_custom/plugins/$plugin ]
|
||||
#echo "$plugin is already installed. Skipping."
|
||||
else
|
||||
omf.log -n white "Installing $plugin... "
|
||||
git clone "https://github.com/oh-my-fish/plugins-$plugin" $fish_path/plugins/$plugin ^ /dev/null
|
||||
omf.log green "√"
|
||||
set -l installed_packages 1
|
||||
end
|
||||
end
|
||||
|
||||
# Theme
|
||||
if [ -e $fish_path/themes/$fish_theme -o -e $fish_custom/themes/$fish_theme ]
|
||||
#echo "$fish_theme is already installed. Skipping."
|
||||
else
|
||||
omf.log -n white "Installing $fish_theme... "
|
||||
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.'
|
||||
function omf.packages.install --argument-names type name -d "Install a plugin or theme"
|
||||
switch $type
|
||||
case '--plugin'
|
||||
if [ -e $fish_path/plugins/$name -o -e $fish_custom/plugins/$name ]
|
||||
#echo "$plugin is already installed. Skipping."
|
||||
else
|
||||
emit omf_package_installing $name
|
||||
git clone "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name ^ /dev/null
|
||||
emit omf_package_installed $name
|
||||
end
|
||||
case '--theme'
|
||||
if [ -e $fish_path/themes/$name -o -e $fish_custom/themes/$name ]
|
||||
#echo "$fish_theme is already installed. Skipping."
|
||||
else
|
||||
emit omf_package_installing $name
|
||||
git clone "https://github.com/oh-my-fish/theme-$name" $fish_path/themes/$name ^ /dev/null
|
||||
emit omf_package_installed $name
|
||||
end
|
||||
case '*'
|
||||
omf.log red 'Unknown option'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,53 +1,52 @@
|
|||
# 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
|
||||
# Update all plugins and themes specified on the $fish_plugins
|
||||
# and $fish_theme variables
|
||||
# Update a plugin or theme
|
||||
#
|
||||
function omf.packages.update -d "Update all plugins and themes"
|
||||
set -l installed_packages 0
|
||||
pushd
|
||||
function omf.packages.update --argument-names type name -d "Update a plugin or theme"
|
||||
pushd # Save current dir
|
||||
|
||||
# Plugins
|
||||
for plugin in $fish_plugins
|
||||
if [ -e $fish_path/plugins/$plugin -a -e $fish_path/plugins/$plugin/.git ]
|
||||
omf.log -n white "Updating $plugin... "
|
||||
echo (cd $fish_path/plugins/$plugin; 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
|
||||
switch $type
|
||||
case '--plugin'
|
||||
if [ -e $fish_path/plugins/$name -a -e $fish_path/plugins/$name/.git ]
|
||||
omf.log -n white "Updating $name "
|
||||
echo (cd $fish_path/plugins/$name; and git pull --rebase > /dev/null) >/dev/null
|
||||
omf.log green "√"
|
||||
set -l installed_packages 1
|
||||
emit omf_package_updated
|
||||
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
|
||||
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
|
||||
|
||||
# Theme
|
||||
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
|
||||
popd # Restore current dir
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user