From 6d9e75776deefb65e71671d2433257818a2b7794 Mon Sep 17 00:00:00 2001 From: Peritia Date: Wed, 4 Mar 2026 09:07:51 +0100 Subject: [PATCH] Clipboard: use a simpler working one --- nixosVista/homeManager/cliphist/main.nix | 43 +++++++++--------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/nixosVista/homeManager/cliphist/main.nix b/nixosVista/homeManager/cliphist/main.nix index 5d879cc..a2014a3 100644 --- a/nixosVista/homeManager/cliphist/main.nix +++ b/nixosVista/homeManager/cliphist/main.nix @@ -21,15 +21,13 @@ home.file.".local/bin/TermClipboardManager" = { executable = true; - text = '' + text = lib.mkForce '' #!/usr/bin/env bash set -euo pipefail preview() { - ID=$(awk '{print $1}' <<< "$1") - TMP=$(mktemp) - cliphist decode "$ID" > "$TMP" 2>/dev/null || { + cliphist decode "$1" > "$TMP" 2>/dev/null || { echo "Failed to decode" rm -f "$TMP" return @@ -40,16 +38,11 @@ if [[ "$MIME" == image/* ]]; then DIM=$(identify -format "%wx%h" "$TMP" 2>/dev/null || echo "unknown") echo "Image • $MIME • $DIM" - echo "────────────────────────────────────────" - - # Dynamic scaling to preview pane - timg --quiet --center \ - --fit \ - --max-size="''${FZF_PREVIEW_COLUMNS}x''${FZF_PREVIEW_LINES}" \ - "$TMP" + echo "----------------------------------------" + timg --quiet --center --fit "$TMP" else echo "Text • $MIME" - echo "────────────────────────────────────────" + echo "----------------------------------------" bat --style=plain --color=always "$TMP" 2>/dev/null || cat "$TMP" fi @@ -58,27 +51,21 @@ export -f preview - HELP="Enter: Copy & Close | Ctrl-Y: Copy (stay) | DEL: Delete | Ctrl-D: Wipe | Ctrl-O: Open Image | Ctrl-I: Toggle Preview" - while true; do SELECTION=$( - cliphist list | \ - fzf \ - --height=100% \ - --border \ - --header="$HELP" \ - --preview 'bash -c "preview \"$1\"" _ {}' \ - --preview-window=right:60% \ - --bind "del:execute-silent(bash -c 'ID=$(cut -d\" \" -f1 <<< \"$1\"); cliphist delete \"$ID\"' _ {})+reload(cliphist list)" \ - --bind "ctrl-d:execute-silent(cliphist wipe)+reload(cliphist list)" \ - --bind "ctrl-y:execute-silent(bash -c 'ID=$(cut -d\" \" -f1 <<< \"$1\"); cliphist decode \"$ID\" | wl-copy' _ {})" \ - --bind "ctrl-o:execute-silent(bash -c 'ID=$(cut -d\" \" -f1 <<< \"$1\"); cliphist decode \"$ID\" > /tmp/clipimg && imv /tmp/clipimg' _ {})" \ - --bind "ctrl-i:change-preview-window(hidden)" ) + cliphist list | \ + fzf \ + --height=100% \ + --border \ + --preview "bash -c 'preview \"\$1\"' _ {}" \ + --preview-window=right:60% \ + --bind "del:execute-silent(bash -c 'cliphist delete \"\$1\"' _ {})+reload(cliphist list)" \ + --bind "ctrl-d:execute-silent(cliphist wipe)+reload(cliphist list)" + ) [[ -z "$SELECTION" ]] && exit 0 - ID=$(awk '{print $1}' <<< "$SELECTION") - cliphist decode "$ID" | wl-copy + cliphist decode <<< "$SELECTION" | wl-copy exit 0 done '';