Live data from Hacker News

Command line tools for productive programmers

earthly.dev

61–70 of 143 posts

Re: Command line tools for productive programmers

#63
post #36

I can't sing the praises enough of entr. Just check out its man page: http://eradman.com/entrproject/ entr lets you watch files and re-run a command any time they change. Whenever I'm working on a script, or go tests, or whatever test-like thing I'm doing that's not in its own bloated test harness, I reach for entr. Great software, does what it's supposed to every time.

I use https://github.com/alexch/rerun for that

Re: Command line tools for productive programmers

#65
post #58

> However, if the directory has many files or sub-directories, tree becomes much less helpful: you only see the last screen full of information as files scroll past you. tree | less

Recently i’ve taken to using nnn for anything like this: https://github.com/jarun/nnn - i never used cli file managers but now, it’s up there with my shell, vim & tmux as a core productivity tool.

Show me files in this dir:

    $ n
Show/hide details for each:

    .
Filter / search file list:

    /
Navigate subdirs (or parents) with vim or arrow keys.

Cd into sub dirs by typing unique chars from dir names:

    ctrl-n
Drop back to shell i started n from but cd into this new dir:

    ctrl-g
Exit n without cd’ing to the new dir i navigated to:

    q
https://github.com/craigjperry2/dotfiles/blob/main/dotfiles/...

Although for deeply nested targets where i already know what im after, i’ll just:

    vim
To launch an fzf fuzzy finder on the (.gitignore aware) results of an “fd” (cross platform alternative to gnu and bsd find)

Re: Command line tools for productive programmers

#66

This is productivity porn for programmers. While obviously these tools are deep and powerful, there is also a learning curve and experimenting wether you can adapt your workflow to them or vice versa. Next year we will have another 5 shiny command line tools, and so on. My point being: only replace your weapons of choice once you are confident you are using them to their full potential and you identify needs that the…

Your main point doesn't do alternative tools justice. It is totally fine to use a newer tool as a novice so you are learning something that will serve you better in the long run, even if you aren't an expert in some other tool from the start

> Your main point doesn't do alternative tools justice. It is totally fine to use a newer tool as a novice so you are learning something that will serve you better in the long run, even if you aren't an expert in some other tool from the start

If you are a novice, you don't start with alternative tools, because they are much more likely to lose popularity, stop being developed, and lose relevance.

Re: Command line tools for productive programmers

#67
post #58

> However, if the directory has many files or sub-directories, tree becomes much less helpful: you only see the last screen full of information as files scroll past you. tree | less

Thanks for reading the article. broot does more than just piping tree to less, it gives you a TUI version of tree that you can navigate along around it. The fuzzy finder in it works like FZF but it keeps everything in a nice compact tree view. It might be overkill but I like it.

Re: Command line tools for productive programmers

#68
post #8

For his usecase of funky i use ~/.bash_aliases, that way i can easily share them between machines. Eg to quickly add a new one: alias als="nvim $HOME/.bash_aliases && source $HOME/.bash_aliases" Be careful with quoting though, got myself into a situation where every new terminal asked for the root password. Shellcheck found the reason quickly. (edit) Another benefit is that those aliases abstract over differences of…

Instead of creating aliases for .., I use this: function ..() { for i in $(seq 1 $1); do cd ..; done } which enables .. # up 1 dir .. 2 # up 2 dirs .. 42 # up 42 dirs Here are some more: https://pilabor.com/blog/2021/03/unix-shell-tricks/

This might be a better alternate to preserve functionality of `cd -`

  function ..() {
    cd $(printf '../%.0s' $(seq 1 $1))
  }

Re: Command line tools for productive programmers

#70
Author here. Thanks for sharing!

Have you seen gron[1]? It can't do everything that jq can, but it is much more in the unix philosophy than jq. It simply flattens and unflattens json out into lines so you can use standard unix tools on it.

   ▶ gron 
   "https://api.github.com/repos/tomnomnom/gron/commits?per_page=1" | fgrep "commit.author"
   json[0].commit.author = {};
   json[0].commit.author.date = "2016-07-02T10:51:21Z";
   json[0].commit.author.email = "mail@tomnomnom.com";
   json[0].commit.author.name = "Tom Hudson";

    ▶ gron "https://api.github.com/repos/tomnomnom/gron/commits? 
   per_page=1" | fgrep "commit.author" | gron --ungron
    [
      {
        "commit": {
          "author": {
            "date": "2016-07-02T10:51:21Z",
            "email": "mail@tomnomnom.com",
            "name": "Tom Hudson"
          }
        }
      }
    ]
[1] https://github.com/tomnomnom/gron
Post reply on HN