mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-01-22 12:52:11 +08:00
Merge pull request #462 from bpinto/external_plugins
Vundle style plugins (external plugins)
This commit is contained in:
commit
91f37c43ce
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
||||||
custom/*
|
custom/*
|
||||||
|
plugins/*
|
||||||
|
themes/*
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
16
README.md
16
README.md
|
@ -14,7 +14,7 @@
|
||||||
|
|
|
|
||||||
<b><a href="#usage">Usage</a></b>
|
<b><a href="#usage">Usage</a></b>
|
||||||
|
|
|
|
||||||
<b><a href="#send-us-your-theme">Contribute</a></b>
|
<b><a href="#contributing">Contributing</a></b>
|
||||||
|
|
|
|
||||||
<b><a href="#uninstall">Uninstall</a></b>
|
<b><a href="#uninstall">Uninstall</a></b>
|
||||||
|
|
|
|
||||||
|
@ -52,9 +52,7 @@ If you want to install it manually, [keep reading](#manual-installation).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Enabling a new plugin or theme is as easy as it should be. Open your fish configuration file `~/.config/fish/config.fish` and specify the theme and the plugins you want to use.
|
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.
|
||||||
|
|
||||||
As an example, to enable rails and git-flow plugins add this line `set fish_plugins git-flow rails` to your configuration file.
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
@ -63,21 +61,15 @@ Before setting down on a theme, you might want to have a go with all themes usin
|
||||||
If you have many functions which go well together, you can create custom plugin in the `custom/plugins/PLUGIN_NAME`
|
If you have many functions which go well together, you can create custom plugin in the `custom/plugins/PLUGIN_NAME`
|
||||||
directory and add to it as many functions as you want.
|
directory and add to it as many functions as you want.
|
||||||
|
|
||||||
If you would like to override the functionality of a plugin distributed with oh-my-fish,
|
|
||||||
create a plugin of the same name in the `custom/plugins/` directory and it will be loaded
|
|
||||||
instead of the one shipped with oh-my-fish.
|
|
||||||
|
|
||||||
If you would like to use your custom theme, move it with the same name in the `custom/themes/` directory
|
If you would like to use your custom theme, move it with the same name in the `custom/themes/` directory
|
||||||
and it will override the original theme in `themes/`.
|
and it will override the original theme in `themes/`.
|
||||||
|
|
||||||
If you just want to override any of the default behavior or add some environment variables,
|
If you just want to override any of the default behavior or add some environment variables,
|
||||||
just add a new file (ending in .load) into the `custom/` directory.
|
just add a new file (ending in .load) into the `custom/` directory.
|
||||||
|
|
||||||
## Send us your theme!
|
## Contributing
|
||||||
|
|
||||||
We are hoping to collect a bunch of themes for our command prompts. You can see existing ones in the [themes](themes/) directory.
|
Create an [issue](https://github.com/bpinto/oh-my-fish/issues) linking to your repository and we will move it to the [oh-my-fish](https://github.com/oh-my-fish) organization.
|
||||||
|
|
||||||
> __Note__: Theme authors, make sure to include a screenshot in your pull request.
|
|
||||||
|
|
||||||
### Manual installation
|
### Manual installation
|
||||||
|
|
||||||
|
|
11
functions/Plugin.fish
Normal file
11
functions/Plugin.fish
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
function Plugin --argument-names name
|
||||||
|
set -g fish_plugins $fish_plugins $name
|
||||||
|
|
||||||
|
if [ -e $fish_path/plugins/$name -o -e $fish_custom/plugins/$name ]
|
||||||
|
import plugins/$name
|
||||||
|
else
|
||||||
|
set_color red
|
||||||
|
echo "Plugin '$name' is not installed. Run 'fish install' to download and install it."
|
||||||
|
set_color normal
|
||||||
|
end
|
||||||
|
end
|
11
functions/Theme.fish
Normal file
11
functions/Theme.fish
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
function Theme --argument-names name
|
||||||
|
set -g fish_theme $name
|
||||||
|
|
||||||
|
if [ -e $fish_path/themes/$name -o -e $fish_custom/themes/$name ]
|
||||||
|
import themes/$name
|
||||||
|
else
|
||||||
|
set_color red
|
||||||
|
echo "Theme '$name' is not installed. Run 'fish install' to download and install it."
|
||||||
|
set_color normal
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,19 +0,0 @@
|
||||||
# Appends the path to the specified path list. If no list specified,
|
|
||||||
# defaults to $PATH
|
|
||||||
function _append_path
|
|
||||||
set_color red
|
|
||||||
echo '_append_path function deprecated. Rename to _prepend_path.' >&2
|
|
||||||
set_color normal
|
|
||||||
|
|
||||||
set -l path PATH
|
|
||||||
|
|
||||||
if test (echo $argv | wc -w) -eq 2
|
|
||||||
set path $argv[2]
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -d $argv[1]
|
|
||||||
if not contains $argv[1] $$path
|
|
||||||
set $path $argv[1] $$path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
20
functions/fish.fish
Normal file
20
functions/fish.fish
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# NAME
|
||||||
|
# fish - Extend default fish binary
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
# Extend fish binary to support plugins and themes installation
|
||||||
|
#
|
||||||
|
function fish -d "Extend fish binary"
|
||||||
|
if test (count $argv) -gt 0
|
||||||
|
switch $argv[1]
|
||||||
|
case 'install'
|
||||||
|
fish.packages --install
|
||||||
|
case 'update'
|
||||||
|
fish.packages --update
|
||||||
|
case '*'
|
||||||
|
command fish $argv
|
||||||
|
end
|
||||||
|
else
|
||||||
|
command fish
|
||||||
|
end
|
||||||
|
end
|
17
functions/fish.log.fish
Normal file
17
functions/fish.log.fish
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# NAME
|
||||||
|
# fish.log - simple log with color
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
# <string> [<string>...]
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
# Simply log a message with a specified color.
|
||||||
|
#
|
||||||
|
function fish.log -d "Simple log with color"
|
||||||
|
switch $argv[1]
|
||||||
|
case '-*'
|
||||||
|
echo $argv[1] (set_color $argv[2])$argv[3..-1](set_color normal)
|
||||||
|
case '*'
|
||||||
|
echo -e (set_color $argv[1])$argv[2..-1](set_color normal)
|
||||||
|
end
|
||||||
|
end
|
28
functions/fish.packages.fish
Normal file
28
functions/fish.packages.fish
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# NAME
|
||||||
|
# fish.packages - Manage all plugins and themes
|
||||||
|
#
|
||||||
|
# SYNOPSIS
|
||||||
|
# fish.packages [OPTIONS]
|
||||||
|
#
|
||||||
|
# OPTIONS
|
||||||
|
# --install
|
||||||
|
# Install all packages
|
||||||
|
# --update
|
||||||
|
# Update all packages
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
# 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'
|
||||||
|
set -l modified_packages 0
|
||||||
|
|
||||||
|
switch $options
|
||||||
|
case "--install"
|
||||||
|
fish.packages.install
|
||||||
|
case "--update"
|
||||||
|
fish.packages.update
|
||||||
|
case "*"
|
||||||
|
fish.log red 'Unknown option'
|
||||||
|
end
|
||||||
|
end
|
36
functions/fish.packages.install.fish
Normal file
36
functions/fish.packages.install.fish
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# NAME
|
||||||
|
# fish.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"
|
||||||
|
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
|
||||||
|
fish.log -n white "Installing $plugin... "
|
||||||
|
git clone "https://github.com/oh-my-fish/plugins-$plugin" $fish_path/plugins/$plugin ^ /dev/null
|
||||||
|
fish.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
|
||||||
|
fish.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 "√"
|
||||||
|
set -l installed_packages 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if [ $installed_packages -eq 0 ]
|
||||||
|
fish.log green 'All plugins were already installed.'
|
||||||
|
end
|
||||||
|
end
|
53
functions/fish.packages.update.fish
Normal file
53
functions/fish.packages.update.fish
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# NAME
|
||||||
|
# fish.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"
|
||||||
|
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... "
|
||||||
|
echo (cd $fish_path/plugins/$plugin; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
fish.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... "
|
||||||
|
echo (cd $fish_custom/plugins/$plugin; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
fish.log green "√"
|
||||||
|
set -l installed_packages 1
|
||||||
|
else
|
||||||
|
#echo "$plugin is not installed or not a git repo. Skipping."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Theme
|
||||||
|
if [ -e $fish_path/themes/$fish_theme -a -e $fish_path/themes/$fish_theme/.git ]
|
||||||
|
fish.log -n white "Updating $fish_theme... "
|
||||||
|
echo (cd $fish_path/themes/$fish_theme; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
fish.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... "
|
||||||
|
echo (cd $fish_custom/themes/$fish_theme; and git pull --rebase > /dev/null) >/dev/null
|
||||||
|
fish.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 ]
|
||||||
|
fish.log green 'No plugins to update.'
|
||||||
|
end
|
||||||
|
|
||||||
|
popd
|
||||||
|
end
|
|
@ -4,17 +4,22 @@ if not set -q fish_custom
|
||||||
set -g fish_custom $fish_path/custom
|
set -g fish_custom $fish_path/custom
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extract user defined functions from path and prepend later to
|
|
||||||
# avoid collisions with oh-my-fish internal functions and allow
|
|
||||||
# users to override/customize plugins, themes, etc.
|
|
||||||
set user_function_path $fish_function_path[1]
|
|
||||||
set -e fish_function_path[1]
|
|
||||||
|
|
||||||
# Add functions defined in oh-my-fish/functions to the path.
|
# Add functions defined in oh-my-fish/functions to the path.
|
||||||
if not contains $fish_path/functions/ $fish_function_path
|
if not contains $fish_path/functions/ $fish_function_path
|
||||||
set fish_function_path $fish_path/functions/ $fish_function_path
|
set fish_function_path $fish_path/functions/ $fish_function_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if set -q fish_plugins
|
||||||
|
set_color red
|
||||||
|
echo '$fish_plugins usage has been deprecated. Please see https://asciinema.org/a/20802.'
|
||||||
|
set_color normal
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q fish_theme
|
||||||
|
set_color red
|
||||||
|
echo '$fish_theme usage has been deprecated. Please see https://asciinema.org/a/20802.'
|
||||||
|
set_color normal
|
||||||
|
end
|
||||||
|
|
||||||
# Add imported plugins, completions and themes. Customize imported
|
# Add imported plugins, completions and themes. Customize imported
|
||||||
# commands via the $fish_path/custom directory, for example create
|
# commands via the $fish_path/custom directory, for example create
|
||||||
|
@ -28,8 +33,5 @@ for load in $fish_custom/*.load
|
||||||
. $load
|
. $load
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prepend extracted user functions so they have the highest priority.
|
|
||||||
set fish_function_path $user_function_path $fish_function_path
|
|
||||||
|
|
||||||
# Make sure to exit with $status of 1 when reloading the framework.
|
# Make sure to exit with $status of 1 when reloading the framework.
|
||||||
or true
|
or true
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
# Path to your oh-my-fish.
|
# Path to your oh-my-fish.
|
||||||
set fish_path $HOME/.oh-my-fish
|
set fish_path $HOME/.oh-my-fish
|
||||||
|
|
||||||
# Theme
|
|
||||||
set fish_theme robbyrussell
|
|
||||||
|
|
||||||
# All built-in plugins can be found at ~/.oh-my-fish/plugins/
|
|
||||||
# Custom plugins may be added to ~/.oh-my-fish/custom/plugins/
|
|
||||||
# Enable plugins by adding their name separated by a space to the line below.
|
|
||||||
set fish_plugins theme
|
|
||||||
|
|
||||||
# Path to your custom folder (default path is ~/.oh-my-fish/custom)
|
# Path to your custom folder (default path is ~/.oh-my-fish/custom)
|
||||||
#set fish_custom $HOME/dotfiles/oh-my-fish
|
#set fish_custom $HOME/dotfiles/oh-my-fish
|
||||||
|
|
||||||
# Load oh-my-fish configuration.
|
# Load oh-my-fish configuration.
|
||||||
. $fish_path/oh-my-fish.fish
|
. $fish_path/oh-my-fish.fish
|
||||||
|
|
||||||
|
# Custom plugins and themes may be added to ~/.oh-my-fish/custom
|
||||||
|
# Plugins and themes can be found at https://github.com/oh-my-fish/
|
||||||
|
Theme 'robbyrussell'
|
||||||
|
Plugin 'theme'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user