News for hackers. Stuff that matters.
Re:Oh My Zsh by Charlie_32 on Tuesday January 23, 2024 @04:54AM (#39101454)
I'm a developer of 10 years, and use the command line for Git, Brew and a few other things, though I'm normally an IDE developer. I believe the CL is as powerful as everyone says, but what are some useful things I can use it for? I use Zsh on a Mac some of the time.
Re:Oh My Zsh by d0mine on Tuesday January 23, 2024 @06:17AM (#39101944)
"Always Bet on Text"

- CLI encourages automation (shell commands are easier to repeat/parametrize then GUI steps) - shell instructions are more git friendly than screenshots (even if a process can't/shouldn't be automated. Commands are easier to document in a reusable/updatable way) - CLI can be used to run tests in a way similar how CI does it (more reproducible)

Command line tools are easier to extend/combine with existing pipelines (rg,jq,xargs): read input from stdin/write output to stdout, report on stderr, return non-zero code on error. It enables you to create adhoc tools that you wouldn't bother otherwise (unrelated: LLMs also have this property by making your skill set much broader (though very shallow with current LLMs)). Shell also has Forth-like property (compose with: retry, timeout, setuid, exec, xargs, env, ssh, etc) https://www.oilshell.org/blog/2017/01/13.html

Re:Oh My Zsh by jay-aye-see-key on Tuesday January 23, 2024 @05:54AM (#39101805)
The two things you can do in the shell you mostly can’t do elsewhere is compose arbitrary commands and store custom commands.

For #1 this blog post has some good examples of quickly chaining together commands (though personally I rarely use xargs) https://drewdevault.com/2020/12/12/Shell-literacy.html

For #2 once you’ve got a command you like, maybe one that generates a metric, you can now re-run it with ease from your history, saved text file, or an alias. You could also share it with teammates.

Please correct me if there are other ways to achieve the above, shell is the only way I know

Re:Oh My Zsh by pjmlp on Tuesday January 23, 2024 @08:33AM (#39103084)
Programming languages REPL environments.
Re:Oh My Zsh by pletnes on Tuesday January 23, 2024 @05:27AM (#39101624)
Rename hundreds of files at a time. Find stupid errors in GB sized csv/json/.. data files. Automate git bisect. Automate workflows by writing a short loop or 3 commands in a row you can easily repeat. Down/upload big datasets. Convert text files any way you can think of.
Re:Oh My Zsh by reactordev on Tuesday January 23, 2024 @05:01AM (#39101484)
Colorful prompt with context information, powerline glyphs, autocomplete, command highlighting, easy navigation through strings, plugins and a plugin ecosystem that extends your shell like crazy
Re:Oh My Zsh by PrimeMcFly on Tuesday January 23, 2024 @04:59AM (#39101478)
> but what are some useful things I can use it for?

I mean, surely you already know?

Anything where feeding input between different tasks, or where you want to use regex, or similar things the cl will be superior.

Re:Oh My Zsh by smcleod on Tuesday January 23, 2024 @05:01AM (#39101483)
10 years in tech and you haven’t optimised your shell?
Re:Oh My Zsh by Brajeshwar on Tuesday January 23, 2024 @05:27AM (#39101627)
20+ years in tech and these days, the first thing that comes to my mind is usually, “Can I walk out of this?” :-)

The idea is to be able to use any computer/system/devices easily instead of one perfectly.

Re:Oh My Zsh by smcleod on Tuesday January 23, 2024 @05:29AM (#39101647)
Gosh, I couldn’t think of anything worse than having to optimise myself for generalist systems
Re:Oh My Zsh by kjellsbells on Tuesday January 23, 2024 @07:11AM (#39102353)
Might be a generational thing.

Some folks grew up on systems that could fail at any time and leave them with nothing but the tools in /sbin to fix it with. No /usr, no bash/zsh, just sh and vi if you were lucky. You learn to love the cool new things, but you still have a mental bag packed with fsck and ed in case you need to bug out.

It's silly, really because no systems are like that any more, but the things you learned at 2am when you were 22 tend to stick with you.

Re:Oh My Zsh by smcleod on Tuesday January 23, 2024 @07:27AM (#39102464)
Perhaps, I’ve been in tech 18+ years though. Cut my teeth on Solaris, AIX, Unix, Linux etc… the good old days!
Re:Oh My Zsh by markstos on Tuesday January 23, 2024 @09:32AM (#39103768)
I strive to speak multiple languages, but I think it still worthwhile to be really good at my primary language of English.

Same with computers and servers. I interact with a lot of them, but my primary computer that I use >80% of the time is worthwhile to optimize with some tooling that's not available on all the others.

Re:Oh My Zsh by pjmlp on Tuesday January 23, 2024 @05:41AM (#39101730)
Coding since 1986 and I touch the shell as much as I have to, If I cared that much I would still be using MS-DOS, and UNIX without X.
Re:Oh My Zsh by Symbiote on Tuesday January 23, 2024 @06:08AM (#39101890)
When you need to rename 5000 files from abcd_small.jpg to abcd.jpg, how do you do that?

  rename s/_small// *_small.jpg
When you have the string ABCD_XYZ in 50 files but you need to change it to DEFG_UVW, how do you do that?

  perl -pi -e 's{ABCD_XYZ}{DEFG_UVW}' **/*(.)
When you need to move all the files ending '.png' into the directory 'PNG', and all the ones ending '.jpg' into 'JPG', how do you do that?

  mkdir JPG PNG;
  for i in *.png *.jpg; mv $i $i:e:u
Re:Oh My Zsh by JNRowe on Tuesday January 23, 2024 @08:36AM (#39103107)
As we're in a zsh story, I'll point out it comes with a clever file renaming interface out of the box¹. It allows full access to all the advanced glob operators zsh provides too².

¹ https://zsh.sourceforge.io/Doc/Release/User-Contributions.ht...

² https://zsh.sourceforge.io/Doc/Release/Expansion.html#Filena...

Re:Oh My Zsh by pjmlp on Tuesday January 23, 2024 @07:10AM (#39102346)
There are GUI tools that do that, and thankfully most scripting languages have a REPL.
Re:Oh My Zsh by Symbiote on Tuesday January 23, 2024 @11:41AM (#39105768)
I'll bet it takes longer to find and use a GUI tool for these.

And a shell is a REPL.

Re:Oh My Zsh by pjmlp on Tuesday January 23, 2024 @12:02PM (#39106081)
You bet wrong, because naturally approaching 50y, I have my tools for quite some time, for the stuff I care about, not random examples on the Internet.

A UNIX shell is a very bad approximation of a real programming language REPL.

It is no accident that sh scripts turn into Perl, Python, Tcl, Lisp,... when one wants to keep sanity.

Re:Oh My Zsh by eggdaft on Tuesday January 23, 2024 @08:55AM (#39103286)
On the second one - if that’s in code than a good IDE will not only do it with a single keypress, but will also (optionally) do it intelligently eg change only in the code, not the comments, show you a browseable preview, and offer undo should you get it wrong.

I like the shell but I also think IDEs are underrated.

Re:Oh My Zsh by cnity on Tuesday January 23, 2024 @06:12AM (#39101906)
X years in tech and you haven't Y.

Pick any X and Y that maximises your ability to feel superior, I suppose.

Re:Oh My Zsh by smcleod on Tuesday January 23, 2024 @06:16AM (#39101939)
Nothing to do with being superior (seriously - it’s just a shell?) - was just surprised (if that’s ok with you).
Re:Oh My Zsh by cnity on Tuesday January 23, 2024 @08:03AM (#39102807)
Honestly, fair enough. I probably misread your tone!
Re:Oh My Zsh by smcleod on Tuesday January 23, 2024 @08:16AM (#39102913)
No worries, it happens and could have just as easily been how I worded it. :)