bpinto/oh-my-fish — pull request #187 by jeremiejig (2014-07-16 01:32:24+00:00)
Title: New Plugin Custom-theme

# Custom Theme

If you don't want to read the README, you to **Some technical stuff.**

## The README

### Why ?
If you want to tinker with your favorite theme, custom-theme will tell you on a pull if an update has been done on the theme.

### What does it do ?

The Plugin will check the latest commit of `(oh-my-fish-path)/themes/$fish_theme/fish_prompt.fish` and `(oh-my-fish-path)/themes/$fish_theme/fish_right_prompt.fish`.

If this commit is more recent than the commit it has previously seen, custom-theme will print a warning.
To aknowledge this warning, just update your custom theme or `touch (oh-my-fish-path)/themes/$fish_theme/fish_prompt.fish`

### Other Features

Many themes use color and unicode that doesn't really fit a system tty ;
* This is why custom-theme also perform a fallback on system `fish_prompt` if it detect that fish is launched from a ttyX.

### How to use ?

This plugin also have a folder in `themes`, do not worry about that just add this plugin like any other `set fish_plugin custom-theme`

## Some technical stuff

* custom-theme is present in `(oh-my-fish)/plugins` and `(oh-my-fish)/themes`.

* custom-theme.load will override `$fish_theme` by `custom-theme` and store the content into `$fish_custom_theme`

* The theme will perform this check:

* If it detect that fish was launched from a tty, it will load the system fish_prompt
(checking `if not set -q COLORTERM`, might have better way to do it)
* will load the custom by default, if a switch is set by a call to customtheme_switch_vanilla (TODO)
* If the user has set `$fish_theme to custom-theme` will load the system theme.

* The plugin will warn you if a change has been detected in `themes/$fish_plugin`
* The plugin use git to get the latest change.
It does so with the function `function __customtheme_check_prompt --on-event fish_prompt`

## Do not merge yet !

On my computer, at first the check is performed in 60ms, I now have reduced the time to 30ms. For reference my system fish_prompt take ~8.7ms.

I think it is still to high, __that is the main reason__ I want to wait before merging.
I'm still working on some others idea to reduce this time.

I just proposed this pull to get some feedback about the usefulness of this plugin. :smile:

There are also some features I'm still working on.