Live data from Hacker News

New(ish) command line tools

jvns.ca

111–120 of 252 posts

Re: New(ish) command line tools

#111

Ah, delta is missing! Right from the docs, it's "[a] syntax-highlighting pager for git, diff, and grep output". [1] https://github.com/dandavison/delta (edit: nevermind, somehow I missed it)

Ah, htmlq [1] is a missing one that's not on the list! Straight from the repo: "Like jq, but for HTML." I find it useful for quickly hacking scripts together and exploring data. Very useful for the iterative process of finding good CSS selectors with the data that I can get without javascript running. --- [1] https://github.com/mgdm/htmlq

I use pup for this. People who tried both, any difference?

https://github.com/EricChiang/pup

Re: New(ish) command line tools

#113
post #3

direnv is such a godsend that I shill for it on every team and in every company now, it's such a great tool.

I read through the direnv docs, but I'm trying to think of how I'd use it. Can you or anyone else give me some examples? Even just listing which directories you have .env or .envrc files in, and what environment variables you use in them.

My biggest use is for configuring database connections. Create something like `FOODATABASE=postgres://user:password@server:port/name` and then whenever I am inside the project, I source the FOODATABASE environment variable wherever it is needed. Another convenience pattern I use with Django is to have a PROJECT_IS_DEBUG key -iff variable is defined, enable extra tracing functionality without requiring any development specific configuration files.

Example server pattern to default to production:

  if "PROJECT_IS_DEBUG" in os.environ:
    DEBUG = True
    ALLOWED_HOSTS = ["*"]
  else:
    # production configuration by default
All for a one-time configuration setup. A further boon of this workflow is that systemd natively supports an EnvironmentFile configuration, so you can re-use the same configuration format from development to production.

Re: New(ish) command line tools

#114
I made a tool back in college called “line” for outputting ranges of line or column numbers.

I got tired of piping head into tail and found it simpler.

Examples:

line file.txt 5 to 9

cat file.txt | line —column 4 to 20

I thought “line” was very Unix sounding and kinda cute, but like a lot of these projects would never make its way into the gnu utils so I thought what’s the point. That and of course to a beginner Awk user, those kind of operations are child’s play. I thought about csv and printing lines between matching words, but it’s all about KISS.

Re: New(ish) command line tools

#115

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

That's a pretty neat trick. I was using `watch -n1` with grep for this occasionally but this is so much better!

Re: New(ish) command line tools

#116

I made a tool back in college called “line” for outputting ranges of line or column numbers. I got tired of piping head into tail and found it simpler. Examples: line file.txt 5 to 9 cat file.txt | line —column 4 to 20 I thought “line” was very Unix sounding and kinda cute, but like a lot of these projects would never make its way into the gnu utils so I thought what’s the point. That and of course to a beginner Awk…

I'd much prefer an ecosystem of interlocking small commands with uniform options than using classic UNIX do-everything tools such as awk. These generally have terrible syntax that's impossible to remember. If I'm gonna drop to a sublanguage other than the shell, I'll use something sane like Python.

Re: New(ish) command line tools

#117

I made a tool back in college called “line” for outputting ranges of line or column numbers. I got tired of piping head into tail and found it simpler. Examples: line file.txt 5 to 9 cat file.txt | line —column 4 to 20 I thought “line” was very Unix sounding and kinda cute, but like a lot of these projects would never make its way into the gnu utils so I thought what’s the point. That and of course to a beginner Awk…

I'd much prefer an ecosystem of interlocking small commands with uniform options than using classic UNIX do-everything tools such as awk. These generally have terrible syntax that's impossible to remember. If I'm gonna drop to a sublanguage other than the shell, I'll use something sane like Python.

To me it feels like someone could rethink the unix tools in the way you're talking about, and maybe it could become a successful and widely-adopted project. Because a suite of tools like this could live alongside the old unix stuff.

The main challenge to doing this well is having good taste and experience. It may be that if you really tried to do this, you'd face tons of UX challenges, and you'd find that tools like awk really were in the sweet spot already.

Re: New(ish) command line tools

#118

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

This is amazing! Is it possible to do the following somehow? - automatically have this for any command that outputs more than 10 lines? - automatically exit when the main command (for example a dev server) exits? - print the output of the main command to stdout after this is done?

Maybe with some clever use of zsh hooks? Here's a gist for zbell; it uses `preexec` and `precmd` to run something right before a command is executed (`preexec`) and right before the prompt is shown again (`precmd`)

https://gist.github.com/jpouellet/5278239

Mine blinks a little light if a command finishes after 30 seconds, and sends me an email if something takes over a minute.

Re: New(ish) command line tools

#119
post #3

direnv is such a godsend that I shill for it on every team and in every company now, it's such a great tool.

I read through the direnv docs, but I'm trying to think of how I'd use it. Can you or anyone else give me some examples? Even just listing which directories you have .env or .envrc files in, and what environment variables you use in them.

Projects I work on wind up with a bin/ directory containing any number of little helper scripts and tools. With direnv that dir can automatically be first in your PATH when you're in the project, but not on it at all when you're elsewhere. Ditto for, say, putting a Python project's virtualenv/bin folder on PATH or a NodeJS project's node_modules/.bin.

Projects I'm on also tend to wind up with an etc/ directory that configures things like PATH and tab completions for a good baseline experience - think of it as standardizing and isolating the snippets many projects tell you to put in your ~/.bashrc to work on the project.

Direnv makes it easy to automatically load those, too.

It really did revolutionize the way I work, by making it trivial to make projects much more self-contained, the way I'd always wanted them to be but hadn't been quite sure how to achieve.

I've only used Nix for managing my personal installed package on OS X so far, but I believe direnv works really well in tandem with Nix - use a Nix file to define your project's dependencies and use direnv to automatically activate all those dependencies whenever you're in the project's directory.

Post reply on HN