aboutsummaryrefslogtreecommitdiff
path: root/archive/rofi-vim-power
diff options
context:
space:
mode:
Diffstat (limited to 'archive/rofi-vim-power')
-rw-r--r--archive/rofi-vim-power26
1 files changed, 26 insertions, 0 deletions
diff --git a/archive/rofi-vim-power b/archive/rofi-vim-power
new file mode 100644
index 0000000..3673119
--- /dev/null
+++ b/archive/rofi-vim-power
@@ -0,0 +1,26 @@
+#!/bin/sh
+set -eu
+
+DB="$HOME/.local/share/cheat-sheets/vim-power.tsv"
+
+[ -f "$DB" ] || exit 1
+
+choice="$(
+ cat "$DB" |
+ rofi -dmenu -i -p 'Vim power ›'
+)"
+
+[ -n "${choice:-}" ] || exit 0
+
+# First column = keystrokes
+keys="$(printf '%s' "$choice" | cut -f1)"
+
+# Clipboard (Wayland/X11)
+if command -v wl-copy >/dev/null 2>&1; then
+ printf '%s' "$keys" | wl-copy
+elif command -v xclip >/dev/null 2>&1; then
+ printf '%s' "$keys" | xclip -selection clipboard
+else
+ printf '%s\n' "$keys"
+fi
+