Code Monkey home page Code Monkey logo

Comments (15)

sentriz avatar sentriz commented on August 24, 2024 1

@shvedes if you're using the master version of cliphist (where the separator is tab character instead of dot)

then you could try ask rofi to hide it for you

cliphist list | rofi -dmenu -display-columns 2 | cliphist decode | wl-copy

this has the benefit of also working for binary data and stuff with unusual white space

from cliphist.

sentriz avatar sentriz commented on August 24, 2024 1

added "faq" section here https://github.com/sentriz/cliphist#faq

from cliphist.

sentriz avatar sentriz commented on August 24, 2024

howdy. unfortunately it's not possible, since the numbers are IDs that reference rows in the cliphist database, which hold the input byte for byte

if you were to take the stdout of your dmenu (eventually piped into wl-copy) literally, you would miss out on newline data, tab characters, images, etc

at least for me these nuances in the text are really important for editing in vim etc

from cliphist.

shvedes avatar shvedes commented on August 24, 2024

Personally, I don't quite understand the purpose or benefit of seeing the ids next to the copied test. I would just like to see the copied test. Would it be possible to add an option that prints the copied items without the ids? Thanks for the awesome program!

Hello. This is a small script that cuts the ID before the copied text and outputs the entire list in rofi. I hope it helps you.

#!/usr/bin/env bash

cliphist_list=$(cliphist list)

cliphist_array=()
while read -r line; do
  cliphist_array+=("${line#*[[:blank:]]}")
done <<< "$cliphist_list"

rofi_options=$(printf "%s\n" "${cliphist_array[@]}")

# Change rofi path to yours
chosen=$(echo -e "${rofi_options}" | rofi -dmenu -i -p "Clipboard:" -theme "$HOME"/.config/rofi/launchers/clipboard/launcher.rasi)

echo "$chosen" | tr -d '\n' | wl-copy

from cliphist.

fritzrehde avatar fritzrehde commented on August 24, 2024

What @sentriz said works well, but for me it prints an empty first column, so there is a bunch of unnecessary whitespace on the left. What I prefer is this:

cliphist list | cut -f 2- | rofi -dmenu | wl-copy

cut automatically uses TAB as a delimiter, and the -f 2- guarantees that it will keep all fields (i.e. fields seperated by tabs) except the first one. This includes an edge case where your copied text contains tabs itself, and then only selecting the second column would not select everything. Hope this helps someone.

from cliphist.

fritzrehde avatar fritzrehde commented on August 24, 2024

However, the problem I get with mine is that leading whitespace also gets deleted, because it is counted as part of the first tab.

from cliphist.

sentriz avatar sentriz commented on August 24, 2024

@fritzrehde that works, but if you skip the "cliphist decode" then all whitespace will be not be preserved. that's why cliphist needs the ID

(also forgot that in my example, updated)

and you're right about rofi printing the extra whitespace seems like a bug in rofi?

$ printf "1\t%s\n" one two three | rofi -dmenu -display-columns 2
image

$ printf "1\t%s\n" one two three | fzf -d $'\t' --with-nth 2

20230412_172327.mp4

from cliphist.

sentriz avatar sentriz commented on August 24, 2024

added a bug/question to rofi about that here:
davatorium/rofi#1834

from cliphist.

sentriz avatar sentriz commented on August 24, 2024

now it's it's fixed with the master version of rofi after davatorium/rofi#1834

so you should be able to do cliphist list | rofi -dmenu -display-columns 2 | cliphist decode | wl-copy

and this will make sure all whitespace from your original selection and images etc are preserved since the "decode" command is used

from cliphist.

fritzrehde avatar fritzrehde commented on August 24, 2024

Cool, that's very helpful. Thanks!

from cliphist.

foxjaw avatar foxjaw commented on August 24, 2024

Can you add fuzzel command too ?

from cliphist.

sentriz avatar sentriz commented on August 24, 2024

PRs are welcome

from cliphist.

foxjaw avatar foxjaw commented on August 24, 2024

PRs are welcome

I meant I donno how to parse the content in fuzzel. If you now how to, help us filter the number out in fuzzel & I'll try to PR.

from cliphist.

sentriz avatar sentriz commented on August 24, 2024

from cliphist.

foxjaw avatar foxjaw commented on August 24, 2024

Strange. I will file a ticket then.
https://codeberg.org/dnkl/fuzzel/issues/288

from cliphist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.