Giter VIP home page Giter VIP logo

yank's People

Contributors

dmarcoux avatar elyscape avatar emmanuelkasper avatar exg avatar fnd avatar fragmede avatar herbygillot avatar infokiller avatar jetm avatar jwilk avatar mptre avatar neutric avatar nmilosev avatar orhun avatar sdelafond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yank's Issues

Fedora RPM's

Hey Anton!

Thank you for this very useful tool!

Sorry for opening an issue, just wanted to let you know that I'm packaging your tool for Fedora. The packages are already available in my COPR (Fedora's user repository host) here:

https://copr.fedorainfracloud.org/coprs/nmilosev/yank/

The instructions are as follows:

# Fedora 24, 25, 26

sudo dnf copr enable nmilosev/yank
sudo dnf install yank -y

yank-cli is then available. Sadly we also have the same problem as Ubuntu, where yank has been yanked (hehe) from us, so we have to use a name override.

I am also in the process of putting your tool in the official repositories, which you can track here: https://bugzilla.redhat.com/show_bug.cgi?id=1422714

Thank you again for your awesome tool!

Cheers,

Nemanja

PS. I can send you a PR for the README.md update with Fedora instructions (COPR for now). Let me know!

Stripping debug info

Hello, while packaging for Fedora, I noticed you are stripping debug info in the Makefile.

Could you provide insight why is that so, and maybe consider leaving the debug information there?

Kind regards,
Nemanja

vi-like keybindings

What do you think about implementing support for hjkl to navigate the cursor?

I'll gladly open a PR for it, but first and foremost - I wanted to get your take on it.

Attempting to compile results in "comparison between signed and unsigned integer expressions" error

Running make gives this output:

cc -Os -pedantic -std=c99 -Wall -Werror -Wextra yank.c -o yank -DVERSION="0.4.0" -DYANKCMD="xsel"
yank.c: In function ‘tsetup’:
yank.c:334:8: error: comparison between signed and unsigned integer expressions [-Werror=sign- compare]
yank.c:334:8: error: signed and unsigned type in conditional expression [-Werror=sign-compare]
cc1: all warnings being treated as errors
make: *** [yank] Error 1

Suggestion: Two-dimensional field navigation

This looks really nice! However, when I watch the GIF, it looks like navigating to the middle of the ps output could be laborious. It would be nice to be able to use the arrow keys and go up/down as well as left/right.

It would be handy to have Emacs-style Ctrl+R/S and/or Vim-style ?//searching, too. :)

`--select-1` option similar to fzf

In case there is only one field - both with or without a pattern - it would be nice to optionally just have that outputted, without any prompt.

Like how --select-1/-1 behaves in fzf.

I would like to do it. But after having a quick look at the source I realised that I am rusty in C.
Perhaps this is where an extra case is needed if the arg is present?

yank/yank.c

Line 348 in 1a7aad0

if (f.nmemb > 0) {

Install failed on Ubuntu 20.04.2

Not sure what's going on here, but after installing I don't have yank on my path somehow:

04:04:47::mlissner@gabbro::~ 
↪ sudo apt install yank
[sudo] password for mlissner: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  xsel
The following NEW packages will be installed:
  xsel yank
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 31.7 kB of archives.
After this operation, 103 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 xsel amd64 1.2.0+git9bfc13d.20180109-3 [20.5 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 yank amd64 1.2.0-1 [11.2 kB]
Fetched 31.7 kB in 0s (84.1 kB/s)
Selecting previously unselected package xsel.
(Reading database ... 397457 files and directories currently installed.)
Preparing to unpack .../xsel_1.2.0+git9bfc13d.20180109-3_amd64.deb ...
Unpacking xsel (1.2.0+git9bfc13d.20180109-3) ...
Selecting previously unselected package yank.
Preparing to unpack .../yank_1.2.0-1_amd64.deb ...
Unpacking yank (1.2.0-1) ...
Setting up xsel (1.2.0+git9bfc13d.20180109-3) ...
Setting up yank (1.2.0-1) ...
Processing triggers for man-db (2.9.1-1) ...
04:05:00::mlissner@gabbro::~ 
↪ ps aux | yank

Command 'yank' not found, but can be installed with:

sudo apt install emboss

04:05:08::mlissner@gabbro::~ 
↪ yank

Command 'yank' not found, but can be installed with:

sudo apt install emboss

04:05:17::mlissner@gabbro::~ 
↪ hash -r
04:05:33::mlissner@gabbro::~ 
↪ yank

Command 'yank' not found, but can be installed with:

sudo apt install emboss

04:05:35::mlissner@gabbro::~ 
↪ bash
04:05:52::mlissner@gabbro::~ 
↪ yank

Command 'yank' not found, but can be installed with:

sudo apt install emboss

Seems like the install went fine, but something ain't right. Could be me, but I don't usually mess around with my path much.

Segmentation fault on OS X

I installed yank from the source by issuing YANKCMD=pbcopy make install. I then tried to use yank by doing the command docker ps | yank and I got a list of the output. I then tried to use the arrow keys and received a segmentation fault.

I am wondering if I may have installed this incorrectly? Any help would be greatly appreciated!

jump across filenames with specific extension

I have a few PDF files with spaces. How do I jump across those for selection?

I have tried something like these but to no avail:

> ls -1 | yank -g '*.pdf'
> ls -1 | yank -g '*.pdf' -d '\r'
> ls -1 | yank -g '*.pdf' -d '\n'

Any ideas?

Yank not using xsel on Ubuntu 20/22?

Hello,

On Ubuntu the yanked selection does not seems to go into the clipboard.

Steps to reproduce:

echo "failure" | xsel -ib
env | yank-cli -d =
# (select any text, say "HOME" and press the enter key)
xsel -ob

Expected results:

xsel -ob should output "HOME".

Obtained result:

xsel -ob outputs "failure".

The following (using xsel -ib as the yank command) works (it outputs "HOME")

echo "failure" | xsel -ib
env | yank-cli -d = -- xsel -ib
xsel -ob

Tested on both Ubuntu 20.04 and Ubuntu 22.04 with yank version 1.2.0-1 and xsel version 1.2.0.

Is there a configuration file or environment variable to tell/force yank to use a given yank command?

Make yank not depend on `xsel`

I noticed that yank is cross-platform and works with technically any clipboard utility. yank also defaults to xsel which depends on X11 and requires extra effort to switch over if you're using Wayland, macOS, Windows, etc or have a headless Linux/BSD server in which case you're toast. However, my project Clipboard works on all those platforms including headless Linux/BSD, so I think it might be worth it to default to cb instead of xsel so that users don't have to think about which platform they have in particular. Does this sound like a reasonable proposition?

How to yank to clipboard?

I used ls | yank and selected the first item but when I paste the contents of clipboard, it doesn't pick up the output from ls.

I'm using yank with ZSH on Ubuntu 18.xx

Suggestion: option to auto-select single field

If there is only one single field (or one line in -l mode), have an option (e.g. -y) to skip the interactive part and just proceed with the only value. This of course shouldn't be the default (least surprise / consistency, ability to Ctrl-C, etc.) but could be useful in some situations.

My use case: kill a specific java program. I want to choose if there are more than one running but directly kill when there is only one. So something like this:

jps | fgrep MyMainClass | yank -y | xargs kill

On a related note, when there is no input (e.g. no matching running java process in the example above), no output / error is displayed but the interactive mode is still active, which can be confusing. Is there a reason not to show a warning on stderr?
In this empty-input case, I would expect -y to proceed with empty value (e.g. for pbcopy and it doesn't disturb xargs) but keep the warning.

Crashes when using -g with -l or -d

Doing something stupid like yank -g'.*' -l < /dev/null crashes yank.

* thread #1, name = 'yank', stop reason = signal SIGSEGV
  * frame #0: 0x0000000800363fb4 libc.so.7`__free [inlined] atomic_load_p(mo=<unavailable>) at atomic.h:55
    frame #1: 0x0000000800363fb4 libc.so.7`__free [inlined] rtree_leaf_elm_bits_read(dependent=<unavailable>) at rtree.h:175
    frame #2: 0x0000000800363fb4 libc.so.7`__free [inlined] rtree_szind_slab_read(dependent=true) at rtree.h:464
    frame #3: 0x0000000800363f74 libc.so.7`__free [inlined] ifree(tsd=<unavailable>, ptr=<unavailable>, tcache=<unavailable>, slow_path=false) at jemalloc_jemalloc.c:2210
    frame #4: 0x0000000800363f6c libc.so.7`__free(ptr=<unavailable>) at jemalloc_jemalloc.c:2397
    frame #5: 0x000000000020247f yank`main(argc=3, argv=0x00007fffffffe7b8) at yank.c:440
    frame #6: 0x000000000020211b yank`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1.c:76

Proposed patch:

diff --git a/yank.c b/yank.c
index 7854fe3..7ee011a 100644
--- a/yank.c
+++ b/yank.c
@@ -421,25 +421,26 @@ main(int argc, char *argv[])
 		err(1, "pledge");
 #endif
 
 	pat = strtopat(" ");
 	while ((c = getopt(argc, argv, "ilvxd:g:")) != -1)
 		switch (c) {
 		case 'd':
 			free(pat);
 			pat = strtopat(optarg);
 			break;
 		case 'g':
 			free(pat);
-			pat = optarg;
+			if ((pat = strdup(optarg)) == NULL)
+				err(1, NULL);
 			rflags |= REG_NEWLINE;
 			break;
 		case 'i':
 			rflags |= REG_ICASE;
 			break;
 		case 'l':
 			free(pat);
 			pat = strtopat("");
 			break;
 		case 'v':
 			puts("yank " VERSION);
 			exit(0);

Why doesn't `... -- <command>` work?

So I see the example for kill and other things is to use xargs and not the -- format?

What is the -- format for running? Is ... yank -- echo same as ... yank | xargs echo i.e. ... echo $yank_result?

When I do ps -a | yank -- kill does not run the kill command propertly becase it prints it's usage.

Can you clarify and update the documentation?

Suggestion: regex for selectable fields

With the seemingly canonical ps example, I'd like to be able to limit the selectable fields to PIDs, so maybe only numbers. Instead of specifying a selector, I'd give a regex (preferably PCRE):

ps | yank -r '\b\d+\b' | xargs kill

yank would then only go through number fields.

What do you think?

Copy all output?

Can you pipe yank and copy all the output of a command with this? Like you can with pbcopy on macOS (e.g. ls -la | pbcopy)

I thought that just piping it without any args would do that like ls -la | yank

Add h,j,k,l bindings

To move around in the text, it would be great if we could use the vimlike keybindings

  • h for left
  • j for down
  • k for up
  • l for right

Does not compile current version with `make`

Well, actually I could compile, but only after removing -std=c99 from Makefile, this is the unmodified compile attempt:

$ make
cc -Os -pedantic -std=c99 -Wall -Werror -Wextra yank.c -o yank  -DVERSION=\"0.6.2\" -DYANKCMD=\"xsel\"
yank.c: In function ‘args’:
yank.c:96:14: error: implicit declaration of function ‘getopt’ [-Werror=implicit-function-declaration]
  while ((c = getopt(argc, (char * const *)argv, "ilvxd:g:")) != -1) {
              ^
yank.c:100:13: error: ‘optarg’ undeclared (first use in this function)
    s = ator(optarg);
             ^
yank.c:100:13: note: each undeclared identifier is reported only once for each function it appears in
yank.c:130:6: error: ‘optind’ undeclared (first use in this function)
  if (optind < argc && strncmp(argv[optind - 1], "--", 3))
      ^
cc1: all warnings being treated as errors
Makefile:10: recipe for target 'yank' failed
make: *** [yank] Error 1

I have tried this on an up-to-date Arch Linux, gcc 5.3.0.

Yank without yanking colors

Say some command has colored output, it should just copy the text and not the escape characters.

Sample :

  • echo "$(tput setaf 1)foo$(tput sgr0) bar" | yank
  • Select foo
  • If you paste foo, you get mfoo

support no-interaction mode

Hi!

Coll utility this one. Is it much against the original idea to implement fully user-non-interactive switches?

-A/--all will simply copy all the stdout to clipbard
-A/--all X will copy X-th match to clipboard

so echo a b | yank -A

  • clipboard contains "a b"

so echo a b | yank -A 2

  • clipboard contains "b"

Setting YANKCMD to "xsel --clipboard"

Hi, I want to copy to the desktop clipboard by default i.e by using xsel --clipboard I would like to make this the default but setting this via YANKCMD at make time appears impossible. Do you have any suggestions? Many thanks.

yanking without input

Yank does not exit directly when there's nothing in stdin. For example echo | yank waits for user input. Moreover, in this example, if I press Enter I get

yank: write: Bad address

Fails to build on 32-bit architectures

Here is a bug report I received after packaging yank for Debian:

| Builds of yank for 32-bit architectures such as i386 have been failing:
|
| yank.c:24:22: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
| #define MIN(x, y) (x < y ? x : y)
| ^
| yank.c:334:8: note: in expansion of macro 'MIN'
| d = MIN((in.v + in.nmemb) - s1,
| ^
| yank.c:24:30: error: signed and unsigned type in conditional expression [-Werror=sign-compare]
| #define MIN(x, y) (x < y ? x : y)
| ^
| yank.c:334:8: note: in expansion of macro 'MIN'
| d = MIN((in.v + in.nmemb) - s1,
| ^
| cc1: all warnings being treated as errors
| Makefile:11: recipe for target 'yank' failed
|
| I'm not sure why this isn't happening for 64-bit architectures; it
| might relate to type promotion rules.

Is this something you'd be willling to fix ?

Cheers,

--Seb

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.