-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_theme.sh
executable file
·57 lines (50 loc) · 1.36 KB
/
show_theme.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash -e
#
# Show theme.
#
# Copyright (c) 2014-2017 Steven Bakker; All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself. See "perldoc perlartistic".
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
dir=${0%/*}
prog=${0##*/}
die() {
echo "$@" >&2
exit 1
}
case $# in
1) theme=$1 ;;
*) die "usage: $prog theme" ;;
esac
is_yaml=false
theme_arg=''
if [[ $theme =~ \.y[a]?ml$ && -f $theme ]]; then
is_yaml=true
theme_arg=$theme
else
if [[ -d $theme ]]; then
if [[ -f $theme/colors.yaml ]]; then
is_yaml=true
theme_arg="$theme/colors.yaml"
elif [[ -f $theme/palette ]]; then
is_yaml=false
theme_arg="$theme"
fi
elif [[ -f colors/$theme/colors.yaml ]]; then
is_yaml=true
theme_arg="colors/$theme/colors.yaml"
elif [[ -f colors/$theme/palette ]]; then
is_yaml=false
theme_arg="colors/$theme"
fi
fi
[[ -n $theme_arg ]] || die "$prog: $theme is not a valid theme file/directory"
if $is_yaml; then
$dir/src/parse_yaml_theme.pl "$theme_arg" show
else
$dir/src/theme_to_yaml.pl --show "$theme_arg"
fi