#!/bin/bash # bman # usage: bman geany # bman --dark geany # tmp dir tmp="/tmp/$RANDOM-$$" #trap '[ -n "$tmp" ] && rm -fr "$tmp"' EXIT mkdir -m 700 "$tmp" || { echo '!! unable to create a tmpdir' >&2; tmp=; exit 1; } if [[ "$1" == "--dark" ]]; then # Dark custom css (apt install fonts-noto) shift csstmp=$(cat < CSS ) css="$(echo "$csstmp" | tr '\n' ' ')" # remove newlines elif [[ "$1" == "--modern" ]]; then # Latin Modern Roman shift csstmp=$(cat < CSS ) css="$(echo "$csstmp" | tr '\n' ' ')" # remove newlines else # Bright custom css (apt install fonts-noto) csstmp=$(cat < CSS ) css="$(echo "$csstmp" | tr '\n' ' ')" # remove newlines fi set -e # Incompatible with ^ cat < "${tmp}/${man}.tmp" 2> /dev/null sed "s|^*|${css}|g" <"${tmp}/${man}.tmp" >"${tmp}/${man}.html" # Insert my custom css before xdg-open "${tmp}/${man}.html" 2> /dev/null # xdg-settings set default-web-browser google-chrome.desktop done