this post was submitted on 16 Jul 2023
171 points (96.7% liked)

linuxmasterrace

2166 readers
1 users here now

A community for Linux enthusiasts.

May your htop stats be low and your beard grow long

Welcome to !linuxmasterrace@feddit.de former r/linuxmasterrace members and existing Lemmyverse citizens: Feel free to join the newly created !linuxmasterrace@feddit.de community.

Let’s make the full transition to the decentralized Fediverse!

founded 1 year ago
MODERATORS
 

I’m moving my posts from Reddit to Lemmy before delete them.

This post is from 2020-09-03.

top 50 comments
sorted by: hot top controversial new old
[–] Lemmchen@feddit.de 17 points 1 year ago (4 children)

Okay, you guys get the once in a liftetime chance to convince me that Bash is not the way to go. I'll eagerly await your proposals.

[–] likeaduck@programming.dev 28 points 1 year ago* (last edited 1 year ago) (5 children)

Zsh, an extended version of the Bourne Shell (sh), offers a plethora of compelling reasons why it surpasses Bash in terms of functionality and customization.

  • Plugin and theme support: Zsh boasts a wide range of plugin frameworks and themes, allowing users to enhance their shell experience and tailor it to their specific needs. The popular Oh-My-Zsh framework is a testament to the vibrant plugin ecosystem available for Zsh.

  • Automatic cd: Zsh simplifies directory navigation by enabling users to change directories simply by typing the name of the desired directory. This feature eliminates the need to type the "cd" command explicitly, saving time and keystrokes.

  • Recursive path expansion: Zsh offers the convenience of shorthand path expansion, allowing users to expand a partial path to its full form recursively. This feature proves particularly useful when dealing with nested directory structures.

  • Spelling correction and approximate completion: Zsh's intelligent auto-correction feature automatically fixes minor typos in directory names, ensuring smooth and error-free command execution. Additionally, Zsh's approximate completion feature suggests potential completions based on the entered command, further streamlining the workflow.

  • Syntax highlighting: Zsh goes beyond mere text display by providing syntax highlighting for command lines, making complex commands more readable and easier to comprehend. This feature enhances code visibility and reduces the likelihood of syntax errors.

  • Advanced scripting capabilities: Zsh offers a more powerful scripting language compared to Bash, enabling users to create intricate and sophisticated shell scripts. This flexibility opens up possibilities for automation and complex task execution.

  • Enhanced customization: Zsh provides users with extensive customization options, allowing them to personalize their shell environment to suit their preferences. From prompt customization to theme selection, Zsh empowers users to create a shell experience that aligns with their workflow and aesthetic choices.

While Zsh undeniably offers a wealth of advantages, it is worth noting that it has a steeper learning curve compared to Bash, especially for users unfamiliar with advanced shell features. Additionally, Zsh consumes more memory due to its more complex data structures and advanced functionality.

[–] Felix@feddit.de 5 points 1 year ago

And Zsh has Tetris built in!

[–] oktoberpaard@feddit.nl 4 points 1 year ago

Some of those options exist in Bash too, but need to be enabled in your profile: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html. Bash is also more like to be available on random machines that you have access to. Lastly, if you’re working a lot with Bash scripts in your (work) environment you might feel more at home using Bash in interactive mode too.

Those are just some counter arguments for the sake of completeness. I think zsh is great, even though I personally don’t use it (yet).

[–] argv_minus_one@beehaw.org 4 points 1 year ago (3 children)

Automatic cd: Zsh simplifies directory navigation by enabling users to change directories simply by typing the name of the desired directory. This feature eliminates the need to type the “cd” command explicitly, saving time and keystrokes.

What if there happens to be a command with the same name?

[–] Still@programming.dev 4 points 1 year ago (1 children)

command goes first

order is shell built in > path > autocd

[–] argv_minus_one@beehaw.org 7 points 1 year ago (2 children)

Then you're likely to enter a command by accident. I would consider that a dangerous misfeature and look to turn it off.

[–] Still@programming.dev 4 points 1 year ago (1 children)

not really tab complete puts a / at the end of autocd directories

[–] argv_minus_one@beehaw.org 4 points 1 year ago (1 children)

Can you not type in the name of the hazardous folder yourself? I'm envisioning trying to autocd into a folder named reboot or something.

[–] Still@programming.dev 1 points 1 year ago (1 children)

then you would type reboot/

[–] argv_minus_one@beehaw.org 1 points 1 year ago* (last edited 1 year ago) (1 children)

Does autocd not work without a slash at the end?

[–] Still@programming.dev 2 points 1 year ago

it does but if you had a file called reboot tab complete would complete the reboot command and not put the slash thwre, adding the slash specifies that it's a directory

[–] gamma@programming.dev 3 points 1 year ago

I've got syntax highlighting enabked, so I always notice the different color when I type a commnand.

[–] branchial@feddit.de 2 points 1 year ago (1 children)

Don't name your directories "rm" or "fdisk" problems solved

[–] argv_minus_one@beehaw.org 1 points 1 year ago

Until I forget about some command or another, and accidentally give a folder the same name.

[–] branchial@feddit.de 2 points 1 year ago

Don't name your directories "rm" or "fdisk" problems solved

[–] zzz@feddit.de 1 points 1 year ago (1 children)

OK GPT, now give me 7 reasons why Bash is better than zsh, please!

[–] gamma@programming.dev 1 points 1 year ago

Yeah, from the first line

Zsh, an extended version of the Bourne Shell (sh)

This screams AI-generated.

[–] cy_narrator@discuss.tchncs.de 1 points 1 year ago

Hi, how can I install zsh in Windows 10?

[–] gamma@programming.dev 6 points 1 year ago* (last edited 1 year ago) (1 children)

There are two massive points no one has mentioned yet.

  • Quoting every expansion isn't necessary in Zsh. Parameters don't split or glob by default.
  • $array actually expands to every element in an array.

Compare this between Bash and Zsh:

a=('/* hello */' 'world!' '  ')
printf '"%s" ' $a
[–] Zucca@sopuli.xyz 3 points 1 year ago* (last edited 1 year ago) (1 children)

$array actually expands to every element in an array.

Very convenient. But ~every shell script is written in bash or POSIX(y) sh. When I need to write shell scripts I begin with busybox sh compability. If it turns out to be too complex, I'll convert to bash. This is because if I ever would publish the script it would have better changes to be accepted as a PR for example. Yes. Bash is a mess. I don't even like it that much. It's okay. But it's more standard then zsh. Although I've seen the tides turn on some occasions, like macOS.

Maybe some day I'll give zsh a second chance.

[–] gamma@programming.dev 1 points 1 year ago

I used to write Bash more than anything, but now the things I write are either simple enough to keep POSIX or complex enough that I miss the extra niceties Zsh provides.

[–] muhyb@programming.dev 3 points 1 year ago

Bash is the way, zsh if you are lazy.

[–] 20gramsWrench@lemmy.dbzer0.com 1 points 1 year ago (1 children)

sh scripts can be run in even the dumbest distro out there, bash, not so much

[–] Lemmchen@feddit.de 1 points 1 year ago

The debate was between zsh and bash, not necessarily POSIX sh.

[–] Thaurin@lemmy.world 12 points 1 year ago (8 children)

Try fish with the tide plugin and the fzf plugin. I can never go back to anything else.

[–] samsy@feddit.de 3 points 1 year ago (1 children)

I love fish, only it annoys me, if I want to run a bash script.

[–] Thaurin@lemmy.world 2 points 1 year ago (1 children)

Why is that? You can still use bash to interpret your bash scripts. Where does it annoy you?

[–] samsy@feddit.de 1 points 1 year ago (1 children)

I have to switch to bash first, and wonder days later, why I can't find it (obviously) in my fish history.

[–] Thaurin@lemmy.world 3 points 1 year ago* (last edited 1 year ago) (2 children)

I mean, doesn’t the script have a hash bang pointing to the bash interpreter?

#!/usr/bin/bash

Or you can just run it like:

bash script.sh
[–] Zucca@sopuli.xyz 3 points 1 year ago (1 children)

#!/usr/bin/env bash for compability. 😉

For example on my system bash is in /bin.

[–] Thaurin@lemmy.world 5 points 1 year ago

Right, of course. I already do that with Python scripts, but with bash old habits die hard, I guess. :)

[–] samsy@feddit.de 2 points 1 year ago (1 children)

I know, well the lazyness is strong in me. Copy and paste.

[–] Thaurin@lemmy.world 4 points 1 year ago* (last edited 1 year ago)

Huh. It’s the first thing I write in any script. :) It actually saves me time.

[–] muhyb@programming.dev 1 points 1 year ago

Haven't tried fish yet but fzf is a godsend.

load more comments (6 replies)
[–] Nuuskis9@feddit.nl 7 points 1 year ago (3 children)

Which distro ships with zsh?

[–] muhyb@programming.dev 1 points 1 year ago

I believe it was Manjaro Bspwm which doesn't exist for quite some time.

[–] Zucca@sopuli.xyz 1 points 1 year ago

Not a distro but macOS does ship zsh but default nowdays.

[–] cyyypher@lemmy.world 1 points 1 year ago

Manjaro, at least the KDE and GNOME editions

[–] vox@sopuli.xyz 3 points 1 year ago

i prefer fish

[–] Xeelee@kbin.social 2 points 1 year ago (1 children)

So what exactly is so great about it?

[–] muhyb@programming.dev 3 points 1 year ago

From my point of view, it's great because I'm lazy.

[–] UntouchedWagons@lemmy.ca 1 points 1 year ago

I wish that oh-my-zsh could be installed at the host level rather than in ~/

[–] Aldileon@feddit.de 1 points 1 year ago (1 children)

What tool are u using for transferring your posts from reddit? Or is this done manual?

[–] muhyb@programming.dev 7 points 1 year ago

Automation can get you blocked from posting apparently, also I didn't have that many posts so I handpicked them.

load more comments
view more: next ›