Live data from Hacker News

New(ish) command line tools

jvns.ca

61–70 of 252 posts

Re: New(ish) command line tools

#61

I could really use a better workflow to refine grep matches. Has anyone made a tool that combines grep (regex search) with fzf (multiple positive/negative patterns)? What I really want is something like: grep pattern1 **/* | grep pattern2 | grep -v exclude_these | grep -v also_exclude The problem is this loses filenames and context lines in the output. I want to apply several positive and negative regexes, and only a…

There's a ripgrep ticket for multiple patterns. No one seems to have come up with a good specification for exactly how it ought to work, so no development has started.

https://github.com/BurntSushi/ripgrep/issues/875

Re: New(ish) command line tools

#62

I could really use a better workflow to refine grep matches. Has anyone made a tool that combines grep (regex search) with fzf (multiple positive/negative patterns)? What I really want is something like: grep pattern1 **/* | grep pattern2 | grep -v exclude_these | grep -v also_exclude The problem is this loses filenames and context lines in the output. I want to apply several positive and negative regexes, and only a…

https://paweldu.dev/posts/fzf-live-repl/

Previous discussion here: https://news.ycombinator.com/item?id=20455857

Also featured in that thread: https://github.com/akavel/up

For example: echo '' | fzf --print-query --preview 'grep -R {q} . 2> /dev/null'

Re: New(ish) command line tools

#63

I could really use a better workflow to refine grep matches. Has anyone made a tool that combines grep (regex search) with fzf (multiple positive/negative patterns)? What I really want is something like: grep pattern1 **/* | grep pattern2 | grep -v exclude_these | grep -v also_exclude The problem is this loses filenames and context lines in the output. I want to apply several positive and negative regexes, and only a…

Not exactly what you’re asking for but similar: I wrote a script called aag, based on ag, that lets you find files that contain multiple matches anywhere in the file. It’s a per-file logical AND of multiple ag searches.

https://gist.github.com/b0o/f0759c84af6ef773a37a499fdb1c05af

Example: you’re trying to find a file that contains the strings “MIT License” (case insensitive), “npm install”, and a match for “react-.*” somewhere in your home directory:

    aag ~ ---- -i "mit license" --- "npm install" --- "react-.*"
The excessive dashes are necessary so that it’s possible to pass different options to each separate invocation of ag.

In case it’s not clear why this is useful, normally ag (or grep) searches are linewise. It’s not so easy if you are looking for things that occur on different lines, and possibly in different orders.

Re: New(ish) command line tools

#65
post #56
post #2

I wrote dug, a cli tool I made to help visualize DNS propagation but is a great learning tool. Didnt make this list though sadly. https://github.com/unfrl/dug https://dug.unfrl.com

Seems your tweet was posted about the time the post was made? dug looks like it will be very useful, thank you

.. in fact I’ve just realised it will help me with an issue and I will be using it tomorrow!

Re: New(ish) command line tools

#66
post #18

Mosh isn't a replacement for SSH, it uses it. > The mosh client logs in to the server via SSH This is a cool list overall though.

The neat thing about mosh is that it doesn't rely on ssh. All you need is a way to launch a process on a remote machine and securely transmit a shared key back to the client. ssh happens to be a useful way to do this, but it's not required

Re: New(ish) command line tools

#67
post #65
post #56

Earlier quoted context omitted.

Seems your tweet was posted about the time the post was made? dug looks like it will be very useful, thank you

.. in fact I’ve just realised it will help me with an issue and I will be using it tomorrow!

Happy to hear it can help you!

Re: New(ish) command line tools

#68
post #6

Earlier quoted context omitted.

direnv should have been part of unix/linux/posix environments from the start. Whenever something's install steps tell you "go add this export statement to your .bashrc" or similar, it never sat well. That sort of thing should be scoped by path, and shell independent -- exactly the thing direnv enables.

I never understood why people were so enamored with direnv, but this makes me understand it a bit. I don't think I need it right now, but I'll keep it in mind for this use case.

I alias ~~ to load .env if it exists, and unload the custom pieces if it doesn’t. I’ve seen people do that with :: as well.

Re: New(ish) command line tools

#69

A simple trick I only figured recently is following logs with fuzzy search: tail -f /var/log/foo.log | fzf +s Or something similar for output from a dev server: make serve | fzf --ansi +s

I've been using tmux for finding, but I think this might be brilliant and stupid simple. Thank you for this! Never thought of piping "live" output or streaming to fzf!!

Re: New(ish) command line tools

#70

I could really use a better workflow to refine grep matches. Has anyone made a tool that combines grep (regex search) with fzf (multiple positive/negative patterns)? What I really want is something like: grep pattern1 **/* | grep pattern2 | grep -v exclude_these | grep -v also_exclude The problem is this loses filenames and context lines in the output. I want to apply several positive and negative regexes, and only a…

Perl would be one option:

  perl -ne '( /foo/ and /bar/ and !/baz/ and !/splat/ ) and print "$ARGV: $_"' *
I didn't include the context part, since that would be more than a one-liner, but it's not hard to do in a short script.
Post reply on HN