pet icon indicating copy to clipboard operation
pet copied to clipboard

Passing in filepath parameters more easily

Open QasimK opened this issue 6 years ago • 1 comments

I think Pet is pretty useful, and love how easy it is to search, share and sync commands via a gist!

All of the commands that I currently use Pet for actually take a filepath as a parameter! This is quite difficult to do at the moment because you cannot auto-complete file paths as you normally can on the shell. This means I often have to copy and paste the filepath - opening a new shell to do this - which is relatively laborious and time-consuming.

I'm not sure how easy it would be to implement auto-complete when entering filenames, but I have an alternative suggestion where pet prints the stored command (leaving in the parameter placeholders), allowing you to copy this into the command-line and edit it to your heart's content. Pet will not execute the command.

This could be used by pet print, pet search --print, or maybe pet exec --print.

QasimK avatar Jul 02 '19 11:07 QasimK

I'm not aware of any improvement in the meantime, but here is a less laborious way to achieve what you are looking for:

  1. Run pet search | xclip
  2. Fill every parameter you can without auto-completion
  3. After <RET>, the half-filled command is in your clipboard
  4. Paste it on the terminal and enjoy your shell's auto-completion

To not lost file path placeholders, you might prefer <input=in.pdf> over <inputPDF>.

firmart avatar Nov 27 '20 22:11 firmart

Very fair ask, this is a nice workaround I've seen in quite a few tickets, I think we should consider building it into pet as you suggest.

As a vision for pet, I do want to see it supporting shell autocomplete in the future but I'm not sure if that's even possible. I'm not a shell expert yet! Will look into it at some point but for now I'm going to look into your suggestion.

RamiAwar avatar Feb 26 '24 19:02 RamiAwar

This does seem pretty simple to implement, will give it a go this week!

https://pkg.go.dev/github.com/atotto/clipboard

RamiAwar avatar Feb 26 '24 19:02 RamiAwar

@firmart @QasimK Pet actually supports adding to clipboard with the clip command, check that out.

As for autocompletion, that's also possible. We'll work on ZSH/bash autocompletion plugins soon enough! Thanks for suggesting this 😄

RamiAwar avatar Mar 05 '24 16:03 RamiAwar

Glad to see the improvement over the years ! Thanks for your contribution @RamiAwar !

firmart avatar Mar 06 '24 10:03 firmart