From 0c53b703f1492d853efdfe44a8e7d56ccd59ec16 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Thu, 22 Sep 2022 13:53:21 +0200 Subject: [PATCH] Add 'fzf' fontnames script --- .bin/fzf-fontnames | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 .bin/fzf-fontnames diff --git a/.bin/fzf-fontnames b/.bin/fzf-fontnames new file mode 100755 index 0000000..848ef06 --- /dev/null +++ b/.bin/fzf-fontnames @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +fn="/tmp/fontnames.txt" + +contains_dash() { + [[ "$1" =~ - ]] +} + +update() { + echo "" > "$fn" + + font_list=$(fc-list -f "%{fullname}\n") + + echo "$font_list" | while read line ; do + first="$(echo "$line" | cut -d',' -f1)" + last="$(echo "$line" | cut -d',' -f2)" + + if $(contains_dash "$first"); then + echo "$last" >> "$fn" + else + echo "$first" >> "$fn" + fi + done +} + +case "$1" in + --update) update;; + *) cat "$fn" | sort | uniq | awk 'NF' | fzf;; +esac