Skip to content

Instantly share code, notes, and snippets.

@jimyang2008
Last active December 29, 2017 07:18
Show Gist options
  • Save jimyang2008/e56692a9402634fb674ad062588af86c to your computer and use it in GitHub Desktop.
Save jimyang2008/e56692a9402634fb674ad062588af86c to your computer and use it in GitHub Desktop.
Replace color names defined in .Xresources for older version of xrdb
#!/bin/bash
err() {
echo "ERROR: $@" >&2
}
: ${INFILE:="$HOME/.Xresources"}
if [[ $# -gt 0 ]]
then
INFILE=$1
fi
test -e $INFILE || {
err "input file '$INFILE' not exist"
exit 1
}
sed_commands=$(awk '/#define / {printf "-e 's/%s/%s/g' ",$2,$3; }' $INFILE)
sed -e '/#define /d' -e '/!!/n' $sed_commands $INFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment