From 46f0a3f981fda55b161edf2c24593eff4f080cb6 Mon Sep 17 00:00:00 2001 From: Bruno Pinto <brunoferreirapinto@gmail.com> Date: Sun, 31 May 2015 12:31:55 +0100 Subject: [PATCH] move fish functions to omf plugin --- .gitignore | 3 +++ README.md | 2 +- functions/Plugin.fish | 2 +- functions/Theme.fish | 2 +- oh-my-fish.fish | 3 +++ functions/fish.fish => plugins/omf/omf.fish | 12 +++++----- plugins/omf/omf.helper.fish | 15 +++++++++++++ .../fish.log.fish => plugins/omf/omf.log.fish | 4 ++-- .../omf/omf.packages.fish | 12 +++++----- .../omf/omf.packages.install.fish | 14 ++++++------ .../omf/omf.packages.update.fish | 22 +++++++++---------- 11 files changed, 56 insertions(+), 35 deletions(-) rename functions/fish.fish => plugins/omf/omf.fish (54%) create mode 100644 plugins/omf/omf.helper.fish rename functions/fish.log.fish => plugins/omf/omf.log.fish (78%) rename functions/fish.packages.fish => plugins/omf/omf.packages.fish (57%) rename functions/fish.packages.install.fish => plugins/omf/omf.packages.install.fish (71%) rename functions/fish.packages.update.fish => plugins/omf/omf.packages.update.fish (73%) diff --git a/.gitignore b/.gitignore index 2d48bdf..11d5053 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ themes/* *.sw? plugins/ta/data/* + +# Track oh-my-fish plugin +!plugins/omf/ diff --git a/README.md b/README.md index d108b75..9d26d48 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ If you want to install it manually, [click here](https://github.com/bpinto/oh-my ## Usage -Open your fish configuration file `~/.config/fish/config.fish` and specify the theme and the plugins you want to use. And then run `fish install` on your terminal to install them. +Open your fish configuration file `~/.config/fish/config.fish` and specify the theme and the plugins you want to use. And then run `omf install` on your terminal to install them. Before setting down on a theme, you might want to have a go with all themes using our quick [theme switcher](https://github.com/bpinto/oh-my-fish/blob/master/plugins/theme/README.md) by typing `theme --help` on your shell. diff --git a/functions/Plugin.fish b/functions/Plugin.fish index fcd0513..85a86ab 100644 --- a/functions/Plugin.fish +++ b/functions/Plugin.fish @@ -5,7 +5,7 @@ function Plugin --argument-names name import plugins/$name else set_color red - echo "Plugin '$name' is not installed. Run 'fish install' to download and install it." + echo "Plugin '$name' is not installed. Run 'omf install' to download and install it." set_color normal end end diff --git a/functions/Theme.fish b/functions/Theme.fish index 546ea5b..ec316d4 100644 --- a/functions/Theme.fish +++ b/functions/Theme.fish @@ -5,7 +5,7 @@ function Theme --argument-names name import themes/$name else set_color red - echo "Theme '$name' is not installed. Run 'fish install' to download and install it." + echo "Theme '$name' is not installed. Run 'omf install' to download and install it." set_color normal end end diff --git a/oh-my-fish.fish b/oh-my-fish.fish index 18f7b9e..3cece54 100644 --- a/oh-my-fish.fish +++ b/oh-my-fish.fish @@ -28,6 +28,9 @@ end # repeat for plugins. import plugins/$fish_plugins themes/$fish_theme +# Always load oh-my-fish plugin +import plugins/omf + # Source all files inside custom directory. for load in $fish_custom/*.load . $load diff --git a/functions/fish.fish b/plugins/omf/omf.fish similarity index 54% rename from functions/fish.fish rename to plugins/omf/omf.fish index 51791ab..7eabbf4 100644 --- a/functions/fish.fish +++ b/plugins/omf/omf.fish @@ -1,20 +1,20 @@ # NAME -# fish - Extend default fish binary +# omf - Oh My Fish helper # # DESCRIPTION # Extend fish binary to support plugins and themes installation # -function fish -d "Extend fish binary" +function omf -d "Oh My Fish helper" if test (count $argv) -gt 0 switch $argv[1] case 'install' - fish.packages --install + omf.packages --install case 'update' - fish.packages --update + omf.packages --update case '*' - command fish $argv + omf.helper end else - command fish + omf.helper end end diff --git a/plugins/omf/omf.helper.fish b/plugins/omf/omf.helper.fish new file mode 100644 index 0000000..5179dcc --- /dev/null +++ b/plugins/omf/omf.helper.fish @@ -0,0 +1,15 @@ +# NAME +# omf.helper - Prints Oh My Fish help +# +# DESCRIPTION +# Prints all functions supported by Oh My Fish helper +# +function omf.helper -d 'Prints all functions supported by Oh My Fish helper' + omf.log normal 'Oh My Fish is a package manager for fish shell. This is a' + omf.log normal 'basic help message containing pointers to more information.' + omf.log normal '' + omf.log normal ' Examples:' + omf.log normal ' omf install' + omf.log normal ' omf update' +end + diff --git a/functions/fish.log.fish b/plugins/omf/omf.log.fish similarity index 78% rename from functions/fish.log.fish rename to plugins/omf/omf.log.fish index 55eb3a8..7b17aab 100644 --- a/functions/fish.log.fish +++ b/plugins/omf/omf.log.fish @@ -1,5 +1,5 @@ # NAME -# fish.log - simple log with color +# omf.log - simple log with color # # SYNOPSIS # <string> [<string>...] @@ -7,7 +7,7 @@ # DESCRIPTION # Simply log a message with a specified color. # -function fish.log -d "Simple log with color" +function omf.log -d "Simple log with color" switch $argv[1] case '-*' echo $argv[1] (set_color $argv[2])$argv[3..-1](set_color normal) diff --git a/functions/fish.packages.fish b/plugins/omf/omf.packages.fish similarity index 57% rename from functions/fish.packages.fish rename to plugins/omf/omf.packages.fish index 857e438..3c08261 100644 --- a/functions/fish.packages.fish +++ b/plugins/omf/omf.packages.fish @@ -1,8 +1,8 @@ # NAME -# fish.packages - Manage all plugins and themes +# omf.packages - Manage all plugins and themes # # SYNOPSIS -# fish.packages [OPTIONS] +# omf.packages [OPTIONS] # # OPTIONS # --install @@ -14,15 +14,15 @@ # Manage all plugins and themes specified on the $fish_plugins # and $fish_theme variables # -function fish.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 switch $options case "--install" - fish.packages.install + omf.packages.install case "--update" - fish.packages.update + omf.packages.update case "*" - fish.log red 'Unknown option' + omf.log red 'Unknown option' end end diff --git a/functions/fish.packages.install.fish b/plugins/omf/omf.packages.install.fish similarity index 71% rename from functions/fish.packages.install.fish rename to plugins/omf/omf.packages.install.fish index 57830d3..ac8dbe3 100644 --- a/functions/fish.packages.install.fish +++ b/plugins/omf/omf.packages.install.fish @@ -1,11 +1,11 @@ # NAME -# fish.packages.install - Install all plugins and themes +# omf.packages.install - Install all plugins and themes # # DESCRIPTION # Install all plugins and themes specified on the $fish_plugins # and $fish_theme variables # -function fish.packages.install -d "Install all plugins and themes" +function omf.packages.install -d "Install all plugins and themes" set -l installed_packages 0 # Plugins @@ -13,9 +13,9 @@ function fish.packages.install -d "Install all plugins and themes" if [ -e $fish_path/plugins/$plugin -o -e $fish_custom/plugins/$plugin ] #echo "$plugin is already installed. Skipping." else - fish.log -n white "Installing $plugin... " + omf.log -n white "Installing $plugin... " git clone "https://github.com/oh-my-fish/plugins-$plugin" $fish_path/plugins/$plugin ^ /dev/null - fish.log green "√" + omf.log green "√" set -l installed_packages 1 end end @@ -24,13 +24,13 @@ function fish.packages.install -d "Install all plugins and themes" if [ -e $fish_path/themes/$fish_theme -o -e $fish_custom/themes/$fish_theme ] #echo "$fish_theme is already installed. Skipping." else - fish.log -n white "Installing $fish_theme... " + 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 - fish.log green "√" + omf.log green "√" set -l installed_packages 1 end if [ $installed_packages -eq 0 ] - fish.log green 'All plugins were already installed.' + omf.log green 'All plugins were already installed.' end end diff --git a/functions/fish.packages.update.fish b/plugins/omf/omf.packages.update.fish similarity index 73% rename from functions/fish.packages.update.fish rename to plugins/omf/omf.packages.update.fish index 513ce46..7075834 100644 --- a/functions/fish.packages.update.fish +++ b/plugins/omf/omf.packages.update.fish @@ -1,26 +1,26 @@ # NAME -# fish.packages.update - Update all plugins and themes +# omf.packages.update - Update all plugins and themes # # DESCRIPTION # Update all plugins and themes specified on the $fish_plugins # and $fish_theme variables # -function fish.packages.update -d "Update all plugins and themes" +function omf.packages.update -d "Update all plugins and themes" set -l installed_packages 0 pushd # Plugins for plugin in $fish_plugins if [ -e $fish_path/plugins/$plugin -a -e $fish_path/plugins/$plugin/.git ] - fish.log -n white "Updating $plugin... " + omf.log -n white "Updating $plugin... " echo (cd $fish_path/plugins/$plugin; and git pull --rebase > /dev/null) >/dev/null - fish.log green "√" + omf.log green "√" set -l installed_packages 1 else if [ -e $fish_custom/plugins/$plugin -a -e $fish_custom/plugins/$plugin/.git ] - fish.log -n white "Updating $plugin... " + omf.log -n white "Updating $plugin... " echo (cd $fish_custom/plugins/$plugin; and git pull --rebase > /dev/null) >/dev/null - fish.log green "√" + omf.log green "√" set -l installed_packages 1 else #echo "$plugin is not installed or not a git repo. Skipping." @@ -30,15 +30,15 @@ function fish.packages.update -d "Update all plugins and themes" # Theme if [ -e $fish_path/themes/$fish_theme -a -e $fish_path/themes/$fish_theme/.git ] - fish.log -n white "Updating $fish_theme... " + omf.log -n white "Updating $fish_theme... " echo (cd $fish_path/themes/$fish_theme; and git pull --rebase > /dev/null) >/dev/null - fish.log green "√" + omf.log green "√" set -l installed_packages 1 else if [ -e $fish_custom/themes/$fish_theme -a -e $fish_custom/themes/$fish_theme/.git ] - fish.log -n white "Updating $fish_theme... " + omf.log -n white "Updating $fish_theme... " echo (cd $fish_custom/themes/$fish_theme; and git pull --rebase > /dev/null) >/dev/null - fish.log green "√" + omf.log green "√" set -l installed_packages 1 else #echo "$fish_theme is not installed or not a git repo. Skipping." @@ -46,7 +46,7 @@ function fish.packages.update -d "Update all plugins and themes" end if [ $installed_packages -eq 0 ] - fish.log green 'No plugins to update.' + omf.log green 'No plugins to update.' end popd -- GitLab