Skip to content

Feature request: cliphist pick #129

@Vaisakhkm2625

Description

@Vaisakhkm2625

FOA, Thanks for making cliphist, such a life saver...

i am looking for a option to directly get a line from clipboard, without printing and then filtering

~ via ☕ via  
❮ cliphist pick 1
ctrl-c tutorial 
this article explain how to use copy paste function
press ctrl+a to select all
now use ctrl+c to copy 

~ via ☕ via  
❮ cliphist pick -2
you copied me?

~ via ☕ via 
❮ cliphist pick -1
you again copied me? this will be the last thing you ever copy   ;rm -rf /

I know i can do echo -e "10\t" | cliphist decode, but it wouldn't support -ve numbers, basically to get the last few things i copied.. atleast i couldn't find a simple way to do it

(chatgpt agreed with me and hallucinated cliphist pick command
image
)

Use cases..

basically to make scripting easier...

eg: compare diff between last 2 items in the clipboard...

#!/bin/sh

# Get the last two clipboard entries
last_item=$(cliphist list | head -n 1 | cliphist decode)
second_last_item=$(cliphist list | sed -n 2p | cliphist decode) # currnet way to do this.., we could also use tail


if [[ -z "$last_item" || -z "$second_last_item" ]]; then
	echo "Not enough items in clipboard history to compare."
	exit 1
fi

temp_file1=$(mktemp)
temp_file2=$(mktemp)

echo "$last_item" >"$temp_file1"
echo "$second_last_item" >"$temp_file2"

# Open vimdiff
#nvim -d "$temp_file1" "$temp_file2"
diff --side-by-side --color=always "$temp_file1" "$temp_file2" | "$PAGER"

rm "$temp_file1" "$temp_file2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions