dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 859811c31efb55d2984171724bfc2e2c3263b7d8
parent 7772416bc01da527399f62522293b167cd9bc33d
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 25 Jul 2019 18:06:23 +0200

Use posix sh for colortheme

Diffstat:
M.local/bin/colortheme | 47++++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/.local/bin/colortheme b/.local/bin/colortheme @@ -1,15 +1,15 @@ -#!/usr/bin/env bash +#!/bin/sh set -e version="0.1.0" slroot=~/.local/lib -function die { +die() { printf '%s \n' "$1" >&2 exit 1 } -function show_help { +show_help() { echo "usage: ${0##*/} [OPTION] COMMAND THEMEFILE" echo "Writes colors from THEMEFILE to:" echo " ~/.Xresources" @@ -22,18 +22,18 @@ function show_help { echo " -v, --version show version information" } -function show_version { +show_version() { echo "${0##*/} version $version" echo "Licensed under GNU Public License v3+" echo "Written by Anders Damsgaard <anders@adamsgaard.dk>" } -function get_theme_color { +get_theme_color() { ! [ -f "$path" ] && die "Error: Could not find $path" grep --ignore-case "^\*\.*$1:" "$path" | awk '{ print $2 }' } -function report_colors { +report_colors() { echo "foreground: $foreground" echo "background: $background" echo "color0: $color0" @@ -55,7 +55,7 @@ function report_colors { echo "cursorColor: $cursorColor" } -function get_colors { +get_colors() { path="$1" ! [ -f "$path" ] && die "Error: Could not find $path" foreground=$(get_theme_color foreground) @@ -79,19 +79,32 @@ function get_colors { cursorColor=$(get_theme_color cursorColor) cursorColor=${cursorColor:-#FF00FF} - if [[ $foreground == "" || $background == "" || $color0 == "" || \ - $color1 == "" || $color2 == "" || $color3 == "" || $color4 == "" || \ - $color5 == "" || $color6 == "" || $color7 == "" || $color8 == "" || \ - $color9 == "" || $color10 == "" || $color11 == "" || $color12 == "" || \ - $color13 == "" || $color14 == "" || $color15 == "" || \ - $cursorColor == "" ]]; then + if [ "$foreground" = "" ] || \ + [ "$background" = "" ] || \ + [ "$color0" = "" ] || \ + [ "$color1" = "" ] || \ + [ "$color2" = "" ] || \ + [ "$color3" = "" ] || \ + [ "$color4" = "" ] || \ + [ "$color5" = "" ] || \ + [ "$color6" = "" ] || \ + [ "$color7" = "" ] || \ + [ "$color8" = "" ] || \ + [ "$color9" = "" ] || \ + [ "$color10" = "" ] || \ + [ "$color11" = "" ] || \ + [ "$color12" = "" ] || \ + [ "$color13" = "" ] || \ + [ "$color14" = "" ] || \ + [ "$color15" = "" ] || \ + [ "$cursorColor" = "" ]; then report_colors die 'Error: One or more colors were not defined' fi } -function set_colors { +set_colors() { get_colors "$1" if [ -f ~/.Xresources ]; then @@ -162,7 +175,7 @@ function set_colors { } -[[ $# -lt 1 ]] && (show_help && exit 1) +[ $# -lt 1 ] && (show_help && exit 1) settheme=0 while :; do @@ -195,7 +208,7 @@ while :; do shift done -[[ $settheme = 1 && $# -lt 1 ]] && die 'Error: No THEMEFILE specified' -[[ $settheme = 1 && $# -gt 1 ]] && die 'Error: More than one THEMEFILE specified' +[ $settheme = 1 ] && [ $# -lt 1 ] && die 'Error: No THEMEFILE specified' +[ $settheme = 1 ] && [ $# -gt 1 ] && die 'Error: More than one THEMEFILE specified' set_colors "$1"