commit 19bb62cc13a7917014783fd508ccdcfdcb7f49be parent 8e7bbbc02f52b112706bae632fd3a6b71e35e65f Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Mon, 4 Mar 2019 18:36:24 +0100 Write outline for colortheme tool Diffstat:
A | links/bin/colortheme | | | 74 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 74 insertions(+), 0 deletions(-)
diff --git a/links/bin/colortheme b/links/bin/colortheme @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -e + +version="0.1.0" +themedir="~/.colors" + +function die { + printf '%s \n' "$1" >&2 + exit 1 +} + +function show_help { + echo "usage: ${0##*/} [OPTION] COMMAND THEMENAME" + echo "where COMMAND is one of the following:" + echo " list: Show all color schemes available in $themedir" + echo " set: Write colors from THEMENAME to ~/.Xresources" + echo " and ~/code/st/config.h, if they exist." + echo "Valid OPTIONS are:" + echo " -h, --help show this message" + echo " -v, --version show version information" +} + +function show_version { + echo "${0##*/} version $version" + echo "Licensed under GNU Public License v3+" + echo "Written by Anders Damsgaard <anders@adamsgaard.dk>" +} + +function show_themes { + ls "$themedir/" +} + +function set_colors { + echo "setting $themedir/$1" + +} + +[[ $# -lt 1 ]] && (show_help && exit 1) + +settheme=0 +while :; do + case "$1" in + -h|-\?|--help) + show_help + exit 0 + ;; + -v|--version) + show_version + exit 0 + ;; + list) + show_themes + exit 0 + ;; + set) + settheme=1 + ;; + --) # end all options + shift + break + ;; + -?*) + die "Error: Unknown option '$1' specified" + ;; + *) # no more options + break + esac + shift +done + +[[ $settheme = 1 && $# -lt 1 ]] && die 'Error: No THEMENAME specified' +[[ $settheme = 1 && $# -gt 1 ]] && die 'Error: More than one THEMENAME specified' + +set_colors "$1"