Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 27 lines (21 sloc) 0.774 kb
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
#!/bin/bash
# changes Xresources colourscheme and saves new value

if [[ $1 == "basic" ]]; then
echo >&2 "$(basename $0): invalid colourscheme"
    exit 1
fi

START=$(($(grep -n "#include.*Xcolours/basic" ~/.Xresources | cut -d ":" -f 1) + 1))

if [[ $# -eq 0 ]]; then
sed -n "$START,$ p" ~/.Xresources | grep -o "Xcolours.*[^\"]" | grep -o "/[^/]\+$" | tr -d "/"
elif [[ -e ~/.Xcolours/$1 || -e $1 ]]; then
COLOUR=$(basename $1)

    if [[ $START -eq 1 ]]; then
echo >&2 "$(basename $0): colourscheme not set: '#include' not found"
        exit 1
    fi

sed --follow-symlinks -i "$START,$ s/Xcolours.*[^\"]/Xcolours\/$COLOUR/" ~/.Xresources
    xrdb -load ~/.Xresources
else
echo >&2 "$(basename $0): colourscheme does not exist"
    exit 1
fi
Something went wrong with that request. Please try again.