diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-05-10 22:57:02 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-05-10 22:57:02 +0200 |
| commit | 3cd9138c9d8fb9be248c75330cca9da47f4d2e8a (patch) | |
| tree | b3b677a9c1a474589f45d20953028a987fa73b80 /rofi-cheat | |
| parent | 83f7fe4b8402bab171d110703a1b1115efbc9b28 (diff) | |
| download | bin-3cd9138c9d8fb9be248c75330cca9da47f4d2e8a.tar.gz bin-3cd9138c9d8fb9be248c75330cca9da47f4d2e8a.zip | |
added a whole bunch of scripts
Diffstat (limited to 'rofi-cheat')
| -rwxr-xr-x | rofi-cheat | 28 |
1 files changed, 28 insertions, 0 deletions
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 |
