[split] Move theme plugin to oh-my-fish/plugin-theme
https://github.com/oh-my-fish/plugin-themepull/2/head
parent
45c23d04e0
commit
41383d8bcb
@ -1,38 +0,0 @@
|
||||
## _theme_ :tophat:
|
||||
> Quick theme switcher.
|
||||
|
||||
## Description
|
||||
Quick theme switcher for _Oh my fish_. _theme_ is smart to auto-complete as you type all the available _oh-my-fish_ themes.
|
||||
|
||||
![mov](https://cloud.githubusercontent.com/assets/8317250/6200763/8593a226-b4c9-11e4-9845-597be49d3233.gif)
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
#### `theme <theme name>`
|
||||
|
||||
Quick switch to theme.
|
||||
|
||||
#### `theme -l --list`
|
||||
|
||||
List available themes.
|
||||
|
||||
#### `theme -r --restore`
|
||||
|
||||
Restore original theme.
|
||||
|
||||
#### `theme -h --help`
|
||||
|
||||
Show usage help.
|
||||
|
||||
## Authors
|
||||
|
||||
+ [Jorge Bucaran](https://github.com/bucaran)
|
||||
|
||||
## Credits
|
||||
|
||||
+ Auto-completions thanks to [Bruno Pinto](https://github.com/bpinto).
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
@ -1,4 +0,0 @@
|
||||
# Add completions when the theme is loaded. Thanks Bruno!
|
||||
complete --command (basename -s.fish (status -f)) \
|
||||
--arguments "(basename (theme.util.get.themes))" \
|
||||
--description "Oh-my-fish theme"
|
@ -1,54 +0,0 @@
|
||||
import plugins/fish-spec
|
||||
import plugins/theme
|
||||
|
||||
function describe_theme -d "theme: quick theme switcher"
|
||||
function before_all
|
||||
set -g __theme_test_last_theme $fish_theme
|
||||
end
|
||||
|
||||
function it_changes_the_current_theme
|
||||
theme bobthefish
|
||||
expect $fish_theme --to-equal bobthefish
|
||||
and expect $fish_function_path --to-contain-all $fish_path/themes/bobthefish
|
||||
end
|
||||
|
||||
function it_restores_the_original_theme
|
||||
theme bobthefish
|
||||
theme -r
|
||||
expect $fish_theme --to-equal $__theme_test_last_theme
|
||||
end
|
||||
|
||||
function it_prints_usage_help
|
||||
expect (theme -h | grep USAGE | sed -E 's/ //g') --to-equal "USAGE"
|
||||
end
|
||||
|
||||
function it_prints_a_list_of_all_themes
|
||||
set -l themes (theme -l)
|
||||
for theme in $fish_custom/themes/* $fish_path/themes/*
|
||||
set theme (basename "$theme")
|
||||
expect (echo "$themes" | grep -o "$theme") --to-equal "$theme"
|
||||
end
|
||||
end
|
||||
|
||||
function it_highlights_the_currently_selected_theme
|
||||
set -l themes (theme -l)
|
||||
expect (echo "$themes" | grep -o "$fish_theme\*") --to-equal "$fish_theme*"
|
||||
end
|
||||
|
||||
function it_can_reload_a_theme_multiple_times
|
||||
theme bobthefish
|
||||
theme fishface
|
||||
theme bobthefish
|
||||
expect $fish_theme --to-equal bobthefish
|
||||
and expect $fish_function_path --to-contain-all $fish_path/themes/bobthefish
|
||||
and expect $fish_function_path --to-not-contain-all $fish_path/themes/fishface
|
||||
end
|
||||
|
||||
function it_returns_1_if_the_theme_does_not_exist
|
||||
set -l improbable_theme ___(date +%s)___
|
||||
set -l ignore_output (theme "$improbable_theme")
|
||||
expect $status --to-equal 1
|
||||
end
|
||||
end
|
||||
|
||||
spec.run $argv
|
@ -1,103 +0,0 @@
|
||||
# NAME
|
||||
# theme - quick theme switcher
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Quick theme switcher for Oh my fish. theme is smart to auto-complete
|
||||
# as you type from the list available _oh-my-fish_ themes.
|
||||
#
|
||||
# SYNOPSIS
|
||||
# theme <theme name>
|
||||
# [-l --list]
|
||||
# [-u --update]
|
||||
# [-r --restore]
|
||||
# [-h --help]
|
||||
#
|
||||
# OPTIONS
|
||||
# theme <theme name>
|
||||
# Quick switch to theme.
|
||||
#
|
||||
# theme -l --list
|
||||
# List available themes.
|
||||
#
|
||||
# theme -u --update
|
||||
# Update theme auto-completions.
|
||||
#
|
||||
# theme -r --restore
|
||||
# Restore original theme.
|
||||
#
|
||||
# theme -h --help
|
||||
# Show usage help.
|
||||
#
|
||||
# AUTHORS
|
||||
# Jorge Bucaran <jbucaran@me.com>
|
||||
# /
|
||||
|
||||
if not set -q __fish_theme_last
|
||||
set -g __fish_theme_last $fish_theme
|
||||
end
|
||||
|
||||
function theme -d "quick theme switcher"
|
||||
set -l usage "
|
||||
USAGE
|
||||
$_ <theme name>
|
||||
Quick switch to theme.
|
||||
|
||||
$_ -l --list
|
||||
List available themes.
|
||||
|
||||
$_ -r --restore
|
||||
Restore original theme.
|
||||
|
||||
$_ -h --help
|
||||
Show usage help.
|
||||
"
|
||||
if test (count $argv) -gt 0
|
||||
set -l option $argv[1]
|
||||
switch $option
|
||||
case -h --help help
|
||||
echo $usage
|
||||
|
||||
case -l --list
|
||||
set -l regex "[[:<:]]($fish_theme)[[:>:]]"
|
||||
if test (uname) != "Darwin"
|
||||
set regex "\b($fish_theme)\b"
|
||||
end
|
||||
set -l color green
|
||||
for theme in (theme.util.get.themes)
|
||||
basename $theme \
|
||||
| sed -E "s/$regex/"(set_color $color)"\1*"(set_color normal)"/"
|
||||
end | column
|
||||
set_color normal
|
||||
|
||||
case -r --restore
|
||||
if set -q __fish_theme_last
|
||||
if test $__fish_theme_last != $fish_theme
|
||||
theme.util.remove.current
|
||||
|
||||
set fish_theme $__fish_theme_last
|
||||
. $fish_path/oh-my-fish.fish
|
||||
end
|
||||
end
|
||||
|
||||
case \*
|
||||
if test -z "$option"
|
||||
echo $usage
|
||||
|
||||
else if test -d $fish_custom/themes/$option -o \
|
||||
-d $fish_path/themes/$option
|
||||
|
||||
theme.util.remove.current
|
||||
|
||||
set fish_theme $option
|
||||
. $fish_path/oh-my-fish.fish
|
||||
|
||||
else
|
||||
echo (set_color f00)"`$option` is not a theme."(set_color normal) ^&2
|
||||
theme --list
|
||||
return 1
|
||||
end
|
||||
end
|
||||
else
|
||||
theme --list
|
||||
end
|
||||
end
|
@ -1,3 +0,0 @@
|
||||
function theme.util.get.themes
|
||||
printf "%s\n" $fish_path/themes/*
|
||||
end
|
@ -1,16 +0,0 @@
|
||||
function theme.util.remove.current
|
||||
# Find previously loaded theme index in function path.
|
||||
set -l index (contains -i -- \
|
||||
$fish_custom/themes/$fish_theme $fish_function_path)
|
||||
|
||||
if test $status -gt 0
|
||||
# Not a custom theme, try a default theme.
|
||||
set index (contains -i -- \
|
||||
$fish_path/themes/$fish_theme $fish_function_path)
|
||||
end
|
||||
|
||||
if test -n "$index"
|
||||
# So Long, and Thanks for All the Fish.
|
||||
set -e fish_function_path[$index]
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue