Live data from Hacker News

Command line tools for productive programmers

earthly.dev

111–120 of 143 posts

Re: Command line tools for productive programmers

#111
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/

I made a slightly different thing:

If you are on

  /home/user/projects/app/src/handlers/
and you want to go to `app/`, you'll do:

  > up src
Or give name of any other child folder/file of `app/`. So if `.git` exists in `app/`,

  > up .git
would work too.

I made it for Fish shell: https://gist.github.com/ajitid/81a4993be410586c038f8b3fc140b...

Re: Command line tools for productive programmers

#113

I'm a VIM-only dev, spend all my day in a Tmux session, and I use the command-line probably a lot more than average. The single best improvement to my command-line workflow I've done in the last few years has been switching shells. First I moved from Bash to ZSH, but about 2 years ago I switched again to Fish. Why I love it: - history completion searches by default, so I can just type part of a command, hit arrow-up…

do you have any trouble running shell scripts? I would suppose that the #! line at the top of the script would save you from problems in most cases.

What about bash one liners?

I had a bad experience with Ubuntu's (Debian's) dash shell many years ago and I've (lazily) just stuck with bash since then.

Re: Command line tools for productive programmers

#114

I'm a VIM-only dev, spend all my day in a Tmux session, and I use the command-line probably a lot more than average. The single best improvement to my command-line workflow I've done in the last few years has been switching shells. First I moved from Bash to ZSH, but about 2 years ago I switched again to Fish. Why I love it: - history completion searches by default, so I can just type part of a command, hit arrow-up…

Can't agree more with this. I too am a (neo)vim + tmux dev, and I made the same progression in shells. Fish just works out of the box. I actually stopped using autojump (see Better CD in the article) because Fish's context-aware auto-completion is that good.

Re: Command line tools for productive programmers

#115

I'm a VIM-only dev, spend all my day in a Tmux session, and I use the command-line probably a lot more than average. The single best improvement to my command-line workflow I've done in the last few years has been switching shells. First I moved from Bash to ZSH, but about 2 years ago I switched again to Fish. Why I love it: - history completion searches by default, so I can just type part of a command, hit arrow-up…

do you have any trouble running shell scripts? I would suppose that the #! line at the top of the script would save you from problems in most cases. What about bash one liners? I had a bad experience with Ubuntu's (Debian's) dash shell many years ago and I've (lazily) just stuck with bash since then.

Not OP, but happy fish user too.

For me, yes I still write my scripts in hashbanged (ba)sh scripts; the only fish I write is my config.fish. Fish might be an objectively better language, I don't want to learn it and prefer keeping writing (ba)sh, as

1. (ba)sh is an evil I know...

2. ... that I must know anyway to work on servers (while fish's "utility" is low as used nowhere but around the fish shell)...

3. ... and shellcheck makes it (a bit) less of a footgun.

When I do need to write a bash one-liner, I just run it in bash :) . But it's a once-in-a-blue-moon occurrence, since pipes are the same, and fish added syntax for && and || a few years ago (before that, they didn't exist and you had to use and; and or;), and added support a few months ago for `FOO=bar ...` direct env.var setting (before that you had to `env FOO bar ...`). So, your typical `thing --blah | grep stuff | awk stuff | whatever && something` generally works in fish.

Re: Command line tools for productive programmers

#116
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.

You can do it with inotify too tho , no ? Great project tho !

'entr' will use inotify where available - the utility is that it's 1) cross-platform and 2) easy to integrate with shell scripting (rather than having to write a more complete inotify or other platform-specific tools).

As an example, I use 'guard' [0] in a docker container, and on test failure it writes out to a file which is shared outside the container. It's easy for me to fire up a shell script that uses 'entr' to watch those files and pop up notifications when tests fail.

[0] https://github.com/guard/guard

Re: Command line tools for productive programmers

#117
post #9

> 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. > broot solves this problem by being aware of the size of your terminal window and adapting its output to fit it. What? You can just pipe `tree` into `less`. The solution isn't to download Yet Another Binary that does this specific thing and doesn't come inst…

Well if we wanna be grumpy this morning... I don't understand why people don't learn how to use `find` properly. And just doing simple things correctly like the `-print0` integration with `xargs -0` to be able to safely send a list of files into rm even if they've got spaces or whatever. I never have much use for `tree` unless I'm trying to take a screenshot and make it look kind of nice.

Re: Command line tools for productive programmers

#118

I've historically spent all my days SSH'd into a remote server in a screen/tmux session writing code in vim and doing various admin/db tasks. Recently I started using vscode with the remote-ssh plugin and it has surprisingly been a pleasant experience. I have an integrated terminal to the remote box and I have full intellisense for coding (I do 80% coding / 20% admin, probably). It took a gestalt flip for me to reali…

I used to keep iterm windows and tabs open but shifted to using pycharm’s integrated terminal.

I use multiple spaces in macOS, with entirely different project contexts. It helped having the labeled terminal tabs coupled to a Pycharm project window.

However, this also let me to realize that the gate commands I was using could be accomplished through pycharms interactive source code management tools.

This helped me realize that there were more powerful things I could do there than in a terminal.

I still find myself using terminal to debug remote environments. But for building, the IDE has taken over over for a lot of my past terminal use.

Re: Command line tools for productive programmers

#120
post #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"; jso…

I personally have settled for fx[1], there's no need to learn yet another tool's syntax, specificities, and quirks. js anonymous functions are valid inputs to the tool.

when the transformation turns to be more complex than expected I can just copy and paste what I've made so far into a nodejs script.

you can also configure a .fxrc file to automatically import npm packages that you might find useful, shortcuts, or your personal functions.

[1] https://github.com/antonmedv/fx

Post reply on HN