Enable loading non-powerline themes via TMP

Without break backwards compatibility.

Should fix issue #6.
This commit is contained in:
2017-04-13 00:17:17 +01:00
parent 6ae659d768
commit 027009b18b
2 changed files with 22 additions and 15 deletions

View File

@@ -25,10 +25,11 @@ A pack of various themes for Tmux.
You can pick and choose a theme via `.tmux.conf` option:
- `set -g @themepack 'block/blue'` (default)
- `set -g @themepack 'block/cyan'`
- `set -g @themepack 'default/gray'`
- `set -g @themepack 'double/megenta'`
- `set -g @themepack 'basic'` (default)
- `set -g @themepack 'powerline/block/blue'`
- `set -g @themepack 'powerline/block/cyan'`
- `set -g @themepack 'powerline/default/gray'`
- `set -g @themepack 'powerline/double/megenta'`
- `...`
## Themes

View File

@@ -3,21 +3,27 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
theme_option="@themepack"
default_theme='block/blue'
default_theme='basic'
get_tmux_option() {
local option="$1"
local default_value="$2"
local option_value="$(tmux show-option -gqv "$option")"
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
local option="$1"
local default_value="$2"
local option_value="$(tmux show-option -gqv "$option")"
if [ -n "$option_value" ]; then
echo "$option_value"
else
echo "$default_value"
fi
}
main() {
local theme="$(get_tmux_option "$theme_option" "$default_theme")"
tmux source-file "$CURRENT_DIR/powerline/${theme}.tmuxtheme"
local theme="$(get_tmux_option "$theme_option" "$default_theme")"
if [ -f "$CURRENT_DIR/${theme}.tmuxtheme" ]; then
tmux source-file "$CURRENT_DIR/${theme}.tmuxtheme"
else
tmux source-file "$CURRENT_DIR/powerline/${theme}.tmuxtheme"
fi
}
main