leandwo / qutebrowser-themes

themes for qutebrowser
20 stars 0 forks source link

fyi script to remove settings from config.py if they are defined in the theme #4

Open Dieterbe opened 2 years ago

Dieterbe commented 2 years ago

the below script will remove all color settings defined in the onedark.py theme - even commented out ones, because those mean use the default - from your config.py, which path should be passed as first arg. it also deletes comments associated with such settings. essentially it deletes all lines matching a setting as well as any preceeding line that is not empty.

there is a bug though where it deletes a section at the end. so make a backup, or keep your config.py in git. you can then just use git add -p to add the desired changes and git checkout -p to undo the buggy change.

#!/bin/bash

file=$1

function process() {
    regex=$(grep c.colors onedark.py | sed 's/^#//' | awk '{print $1}' | tr '\n' '|' | sed -e 's/|$//' -e 's/\./\\./g')
    while read line; do
        if echo $line | egrep -q $regex; then
            del=true
        fi
        if [[ "$del" == false ]]; then
            echo "$line"
        fi
        if [[ "$line" == "" ]]; then
            del=false
        fi
    done < <(tac $file)
}

process | tac > $file.new
mv $file.new $file