Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Not even if it's an example of a one-liner in bash - wrap that line to make it easier to read.

This is the one case (that I can think of right now) where I don't agree.

As part of a larger script, sure, wrap the line so it's not way longer than all the other lines.

But a single shell command in isolation is always easier to read as a single line, if sufficient horizontal space is available.



When writing outside of a terminal, I wrap single-line shell commands with backslashes and space indentation. The breaks are at logical clauses, as if writing a conventional programming language. I find this much more readable than the alternatives. Often my terminal will also get it this way, from a copy-paste.

This also usually helps in documentation.


If I have to do it twice I stick it in a proper script, with some comments, so I remember what it all does next time I go to do it. I do this particularly for stuff like complex ffmpeg filter chains where I need to do a lot of stuff to a video file. By simply running the bash script, at some later date I can get it to remind me what it does, and suitably mangle the video file.

Then, later on, often weeks later, I use command history to scroll back through everything I've typed until I find something that looks vaguely like what I originally typed, or I don't find it and figure it all out from scratch again, having totally forgotten about the bash script I wrote.

I suspect this workflow is surprisingly common.


Yeah, but how many times do you see a one-liner that's in a nice little boxout, but there's a scrollbar and you need to slide it backwards and forwards to read the whole thing?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: