Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: cliphist pick #129

Open
Vaisakhkm2625 opened this issue Dec 18, 2024 · 0 comments
Open

Feature request: cliphist pick #129

Vaisakhkm2625 opened this issue Dec 18, 2024 · 0 comments

Comments

@Vaisakhkm2625
Copy link

Vaisakhkm2625 commented Dec 18, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant