Commit 46f0a3f9 authored by Bruno Pinto's avatar Bruno Pinto

move fish functions to omf plugin

parent 8b35fae1
...@@ -8,3 +8,6 @@ themes/* ...@@ -8,3 +8,6 @@ themes/*
*.sw? *.sw?
plugins/ta/data/* plugins/ta/data/*
# Track oh-my-fish plugin
!plugins/omf/
...@@ -35,7 +35,7 @@ If you want to install it manually, [click here](https://github.com/bpinto/oh-my ...@@ -35,7 +35,7 @@ If you want to install it manually, [click here](https://github.com/bpinto/oh-my
## Usage ## 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. 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.
......
...@@ -5,7 +5,7 @@ function Plugin --argument-names name ...@@ -5,7 +5,7 @@ function Plugin --argument-names name
import plugins/$name import plugins/$name
else else
set_color red 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 set_color normal
end end
end end
...@@ -5,7 +5,7 @@ function Theme --argument-names name ...@@ -5,7 +5,7 @@ function Theme --argument-names name
import themes/$name import themes/$name
else else
set_color red 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 set_color normal
end end
end end
...@@ -28,6 +28,9 @@ end ...@@ -28,6 +28,9 @@ end
# repeat for plugins. # repeat for plugins.
import plugins/$fish_plugins themes/$fish_theme import plugins/$fish_plugins themes/$fish_theme
# Always load oh-my-fish plugin
import plugins/omf
# Source all files inside custom directory. # Source all files inside custom directory.
for load in $fish_custom/*.load for load in $fish_custom/*.load
. $load . $load
......
# NAME # NAME
# fish - Extend default fish binary # omf - Oh My Fish helper
# #
# DESCRIPTION # DESCRIPTION
# Extend fish binary to support plugins and themes installation # 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 if test (count $argv) -gt 0
switch $argv[1] switch $argv[1]
case 'install' case 'install'
fish.packages --install omf.packages --install
case 'update' case 'update'
fish.packages --update omf.packages --update
case '*' case '*'
command fish $argv omf.helper
end end
else else
command fish omf.helper
end end
end end
# 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
# NAME # NAME
# fish.log - simple log with color # omf.log - simple log with color
# #
# SYNOPSIS # SYNOPSIS
# <string> [<string>...] # <string> [<string>...]
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# DESCRIPTION # DESCRIPTION
# Simply log a message with a specified color. # 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] switch $argv[1]
case '-*' case '-*'
echo $argv[1] (set_color $argv[2])$argv[3..-1](set_color normal) echo $argv[1] (set_color $argv[2])$argv[3..-1](set_color normal)
......
# NAME # NAME
# fish.packages - Manage all plugins and themes # omf.packages - Manage all plugins and themes
# #
# SYNOPSIS # SYNOPSIS
# fish.packages [OPTIONS] # omf.packages [OPTIONS]
# #
# OPTIONS # OPTIONS
# --install # --install
...@@ -14,15 +14,15 @@ ...@@ -14,15 +14,15 @@
# 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 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 set -l modified_packages 0
switch $options switch $options
case "--install" case "--install"
fish.packages.install omf.packages.install
case "--update" case "--update"
fish.packages.update omf.packages.update
case "*" case "*"
fish.log red 'Unknown option' omf.log red 'Unknown option'
end end
end end
# NAME # NAME
# fish.packages.install - Install all plugins and themes # omf.packages.install - Install all plugins and themes
# #
# DESCRIPTION # DESCRIPTION
# Install all plugins and themes specified on the $fish_plugins # Install all plugins and themes specified on the $fish_plugins
# and $fish_theme variables # 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 set -l installed_packages 0
# Plugins # Plugins
...@@ -13,9 +13,9 @@ function fish.packages.install -d "Install all plugins and themes" ...@@ -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 ] if [ -e $fish_path/plugins/$plugin -o -e $fish_custom/plugins/$plugin ]
#echo "$plugin is already installed. Skipping." #echo "$plugin is already installed. Skipping."
else 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 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 set -l installed_packages 1
end end
end end
...@@ -24,13 +24,13 @@ function fish.packages.install -d "Install all plugins and themes" ...@@ -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 ] if [ -e $fish_path/themes/$fish_theme -o -e $fish_custom/themes/$fish_theme ]
#echo "$fish_theme is already installed. Skipping." #echo "$fish_theme is already installed. Skipping."
else 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 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 set -l installed_packages 1
end end
if [ $installed_packages -eq 0 ] if [ $installed_packages -eq 0 ]
fish.log green 'All plugins were already installed.' omf.log green 'All plugins were already installed.'
end end
end end
# NAME # NAME
# fish.packages.update - Update all plugins and themes # omf.packages.update - Update all plugins and themes
# #
# DESCRIPTION # DESCRIPTION
# Update all plugins and themes specified on the $fish_plugins # Update all plugins and themes specified on the $fish_plugins
# and $fish_theme variables # 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 set -l installed_packages 0
pushd pushd
# Plugins # Plugins
for plugin in $fish_plugins for plugin in $fish_plugins
if [ -e $fish_path/plugins/$plugin -a -e $fish_path/plugins/$plugin/.git ] 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 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 set -l installed_packages 1
else else
if [ -e $fish_custom/plugins/$plugin -a -e $fish_custom/plugins/$plugin/.git ] 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 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 set -l installed_packages 1
else else
#echo "$plugin is not installed or not a git repo. Skipping." #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" ...@@ -30,15 +30,15 @@ function fish.packages.update -d "Update all plugins and themes"
# Theme # Theme
if [ -e $fish_path/themes/$fish_theme -a -e $fish_path/themes/$fish_theme/.git ] 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 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 set -l installed_packages 1
else else
if [ -e $fish_custom/themes/$fish_theme -a -e $fish_custom/themes/$fish_theme/.git ] 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 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 set -l installed_packages 1
else else
#echo "$fish_theme is not installed or not a git repo. Skipping." #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" ...@@ -46,7 +46,7 @@ function fish.packages.update -d "Update all plugins and themes"
end end
if [ $installed_packages -eq 0 ] if [ $installed_packages -eq 0 ]
fish.log green 'No plugins to update.' omf.log green 'No plugins to update.'
end end
popd popd
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment