Prettier interface
[iomenu.git] / io-tty-theme
blob80c86e9a6a9cac75d00b77ec9fb183e5c6188233
1 # ---- |
2 #  |   |--. ,--. --.-. ,--.
3 #  |   |  | |--' | | | |--'
4 #  '   '  ' `--' ' ' ' `--'                                           2016-10-27
5 #_______________________________________________________________________________
7 # Set a x-ressource theme to the tty
9 # Set the directory where you usually set your themes:
10 THEMES="$HOME/.config/themes"
12 # Then run this script, with either one theme name as argument, or as is, to
13 # run it in an interactively filter.  You can set the filter to something like
14 # fzf, fzy, slmenu, pick, pick, selecta...
15 FILTER='iomenu'
17 # if no argument
18 if [ $# = 0 ]
19 then
20         # interactively prompt for a color theme
21         ls "$THEMES" | $FILTER
22 else
23         # otherwise use the one from the command line argument
24         printf %s $1
25 fi | xargs -i sed -rn '
27 # remove comment lines
28 /^[[:space:]]*!.*/ d
30 # remove empty lines
31 /^[[:space:]]*$/ d
33 # convert colors numbers from decimal to hexadecimal
34 s/color10/colorA/
35 s/color11/colorB/
36 s/color12/colorC/
37 s/color13/colorD/
38 s/color14/colorE/
39 s/color15/colorF/
41 # print escaped color names
42 s/.*\.color([0-9A-F])[[:space:]]*:[[:space:]]*#/\1/ p
44 ' "$THEMES/{}" | while read color
46         # TTY color escape codes
47         printf '\033]P%s' "$color"
48 done
50 clear