From 3cd9138c9d8fb9be248c75330cca9da47f4d2e8a Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Sun, 10 May 2026 22:57:02 +0200 Subject: added a whole bunch of scripts --- rofi-cheat | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 rofi-cheat (limited to 'rofi-cheat') diff --git a/rofi-cheat b/rofi-cheat new file mode 100755 index 0000000..a0440b6 --- /dev/null +++ b/rofi-cheat @@ -0,0 +1,28 @@ +#!/bin/sh +set -eu + +DB_DIR="$HOME/.local/share/cheat-sheets" +[ -d "$DB_DIR" ] || exit 1 + +# Stage 1: pick a sheet +sheet="$( + ls "$DB_DIR"/*.tsv 2>/dev/null | + xargs -I{} basename {} .tsv | + rofi -dmenu -i -p 'Cheat sheet ›' +)" || exit 0 +[ -n "${sheet:-}" ] || exit 0 + +db="$DB_DIR/${sheet}.tsv" +[ -f "$db" ] || exit 1 + +# Stage 2: search within the sheet +choice="$(rofi -dmenu -i -p "${sheet} ›" < "$db")" || exit 0 +[ -n "${choice:-}" ] || exit 0 + +# Copy first column (keystroke/command) to clipboard +keys="$(printf '%s' "$choice" | cut -f1)" +if command -v xclip >/dev/null 2>&1; then + printf '%s' "$keys" | xclip -selection clipboard +elif command -v xsel >/dev/null 2>&1; then + printf '%s' "$keys" | xsel --clipboard --input +fi -- cgit v1.3