Bash vs Zsh

What are valid reasons for switching from Bash to Zsh? The main issue I'm concerned about is that I'll have to learn new script language (I'm getting to old to learn shit just to be "cool") to do my shit. Are they reasonably compatible? Does Zsh have a POSIX compatibility mode?

Other urls found in this thread:

pubs.opengroup.org/onlinepubs/9699919799/
grymoire.com/Unix/CshTop10.txt
twitter.com/NSFWRedditGif

Literally none. Both shells lack common programming features like multi-dimensional arrays or structures. Zsh is also bloated as fuck which makes it all the more ironic.
Use ksh93 (original from AT&T), preferably a recent version (93u+ or 93v) because older ones have a few annoying bugs when used interactively.

I've seen a lot shilling for Zsh so I though I'll give it a chance. Also anybody agrees with me that scripting in shells is PITA? For anything longer than 10 lines I prefer Python/Perl

I use shell for scripting 99% of the time, but that's because I administer a wide variety of UNIX and Linux systems where the only common ground is POSIX sh and some portable dialect of Korn Shell (ksh88 mostly, ksh93 if the stars align).
I guess I could use Perl too, but I'm not that good at it and I won't risk some obscure incompatibility backfiring.

How do you check POSIX compliance of your script? Do you use shellcheck or just some posix compliance option for your shell? I hope you don't need to literally look into the pubs.opengroup.org/onlinepubs/9699919799/

I test with dash (Debian Almquist shell) while writing the script on a Linux machine and also use shellcheck because it detects some other common errors and warnings.

>shellcheck
Thanks for mentioning this. It told me how to optimise a ksh93 script I had. I was doing mathematics suboptimally.

>What are valid reasons for switching from Bash to Zsh?
Vi keys supports. It's miles ahead of what bash or readline can do.
>The main issue I'm concerned about is that I'll have to learn new script language (I'm getting to old to learn shit just to be "cool") to do my shit.
Just put #!/bin/sh or #!/bin/bash at the top of your scripts.

I've made some observations about people who use zsh and I know why most of them think it's better than bash.

People switch to zsh either to be special snowflakes or because they see cool zsh prompts in desktop threads or because they hear it has better completion (I personally don't think it does).
Most of them have no idea that the same look can be achieved with bash, that you can embed commands into your PS1, they probably haven't heard of PS2, PS3 and PS4 and they probably don't even know what readline is.
They haven't heard of inputrc, they don't know how to add custom keybinds to macros in bash, they don't know that you can change the editing mode of the interactive shell to be Vi-like.
They don't know about incremental search nor do they know about different completion settings.

Some may say that it's better for scripting, but scripting in a non standard shell is pointless, since you still need to know POSIX scripting and in most cases bash, since it has more features than sh and unlike zsh it's everywhere.
If you want to use a sane language for scripting, use python or if you're working on a larger project, you might also want to consider using a non interpreted programming language like C.

Zsh users are mostly ignorant impresionable people, hipsters of all sorts including nu-male macfag webdev sitting at starbucks types and most of them like to pretend to be cool for using a non standard shell while barely having scratched the surface of bash/readline and I do not want to be associated with them in any way.
In order to make an informed decision about which shell to use, you've got to at least know the basics of both shells and what readline is and what you can do with it.

I personally don't see a valid reason to switch to zsh. I think zsh is bloat mostly for the sake of it.
There might be valid reasons to use zsh, but most people certainly don't do it for valid reasons.

>Vi keys supports
kill yourself, retard

>Not using Vi keys in your shell

Zsh's Vi emulation is god tier compared to what readline/bash does. A single example would be the surround text object: in zsh you can do cs"' to change the surrounding double quotes in single quotes (it doesn't look useful when you see it like this but it's actually quite handy). Readline/bash won't do this.

> zsh
> That bloat

>>Not using Vi keys in your shell
I am
>not using Vi keys in bash

>Zsh's Vi emulation is god tier compared to what readline/bash does
no, you're just retarded
>in zsh you can do cs"' to change the surrounding double quotes in single quotes
nice useless feature (aka bloat)

>they don't know that you can change the editing mode of the interactive shell to be Vi-like
how can i do this?

imagine being this salty about a fucking shell

I know you're just trolling but I feel compelled to answer. It's very useful when you want to turn an interpreted string into a literal string. Way faster than just doing F"r';. especially if the given string contains backslashed double quotes.

fish

think it is about time, fucking zshfags shitting up threads, acting like they are hot shit with their screenfetch crap.
get the fuck out of here with that bullshit.

the proper way would be to make an ~/.inputrc like so
$include /etc/inputrc

set editing-mode vi

set show-mode-in-prompt on

# if you're using bash 4.4 or newer, you set the mode indicator look like so
set vi-ins-mode-string [\1\e[0;32m\2>\1\e[0m\2]
set vi-cmd-mode-string [\1\e[0;32m\2:\1\e[0m\2]

# some more useful stuff
$if mode=vi

set keymap vi-insert
#Keybinds for insert mode

# Ctrl+l for clear
"\C-l": clear-screen

# Alt+e to glob patterns without executing, eg: 'rm *x'
"\ee": glob-expand-word

# Alt+] (Alt+[) to cycle thru completions.
# maybe bind another function here to display the selected item
"\e]": menu-complete
"\e[": menu-complete-backward

# Unset arrow keys
"\eOD":""
"\e[D":""
"\eOC":""
"\e[C":""
"\eOA":""
"\e[A":""
"\eOB":""
"\e[B":""

set keymap vi-command
# Keybinds for command mode

"\ee": glob-expand-word

# Unset arrow keys
"\eOD":""
"\e[D":""
"\eOC":""
"\e[C":""
"\eOA":""
"\e[A":""
"\eOB":""
"\e[B":""
$endif

god I hate zshfags so much

>It's very useful when you don't know what you're doing

Or when you're iterating through the commands you want to run.

Can ksh use Vi keybinds?

apparently yes

ooh! thanks! gonna play around with this.

why is everything bloated for you guys? if you have over 8GB RAM your machine can take most day-to-day work that you throw at it, you know. It's not the 80s anymore, we deserve good looking and functional things out of the box.

any reason to use zsh over fish?

VISUAL=vi
That's all. No readline crap needed.

spoken like a true macfag, aka the main zshfags

This.
The only sane user in this thread.

How is more RAM going to help you with zsh being slow as molasses?

This.
Zsh just fucks with the shell loading time.
All the plugins also make the whole terminal slow as fuck.
You won't ever need the half of it in your lifetime anyway.
Don't be a sjw and customize your shell from scratch. Unless you have a job.

t. salty neet

This. Added benefit is that it is portable.

POSIX compliance, if you don't care about that then fish is pretty nice for out-of-the-box "it just werks" experience

>hurr zsh is bloated and slow
If you use something like oh-my-zsh, then sure. If you loaded ten thousand lines of shell script distributed across a hundred files in bash, it would be slow and bloated too.

Out of the box, zsh is just as fast as bash. It has some extra optional features like improved tab completion and live syntax highlighting, and that alone makes it a far better shell.
But then fags go and load these massive frameworks into it for no reason and it bogs the shell down and then you idiots blame the shell instead of yourselves.

When I was a noob I used oh-my-zsh too, and the time it took to start a new shell (on my admittedly very old laptop) was nearly an entire second - unacceptable for a shell. Since then, I looked at what features of oh-my-zsh I actually used and liked, and just turned on those options directly in my zsh config and dumped oh-my-zsh. Now my experience is exactly the same but my zsh startup time is 0.08 seconds.

zsh is great. zsh frameworks are cancer

>sane person
>uses 6 reddit spaces of pure autism

tcsh

don't mention that evil here

it's not evil, it's beautiful. and you are ugly.

Are you sure you're talking about ZSH and not oh-my-zsh?
time bash -c 'for i in $(seq 1 100) ; do printf "hello\n" ; done' 0.00s user 0.00s system 84% cpu 0.003 total
zsh -c 'for i in $(seq 1 100) ; do printf "hello\n" ; done' 0.00s user 0.00s system 97% cpu 0.003 total
And that's with nothing in my bashrc and a ton of files sourced in my zshrc.

what the fuck are you doing

Just timing a small for loop to try and prove that there's no startup-time lag. I know I could just have timed with exit but I wanted to make sure that there wasn't any kind of optimization going on.

Is the love for ksh?

>zsh-autosuggestions
this plugin has saved me countless hours

>tcsh
>beautiful
grymoire.com/Unix/CshTop10.txt

>The main issue I'm concerned about is that I'll have to learn new script language (I'm getting to old to learn shit just to be "cool") to do my shit.
Are you really that dumb? You can still write bash scripts and run them through bash. Holy fuck how can people like you exist? Shouldn't you be forgetting how to breathe every 5 minutes or so? It's really amazing how many functioning retards find their ways to Sup Forums

You described me perfectly. Honestly I don't do any scripting, but I switched to zsh for some convenience features.
For example, zsh has case insensitive tab auto complete, and it also lets you type a few letters of a directory, then it will autocomplete all the directory names (i.e. I could type cd /pic/scr/ph/ric and it would complete to /Pictures/Screenshots/Phone/Ricing )

Can bash do all these things too?

DELETE THIS

I use zsh too but I'm pretty sure bash can do such basic things.

Indeed, I was talking about oh-my-zsh.
Apologies

Don't use zsh for scripting. Use dash and make your scripts POSIX compliant.
Use zsh for the interactive shell.

bash also has case insensitive auto complete

I started using it (and by it I mean oh-my-zsh) purely for the case-insensitive tab completions. Can probably do it in bash too but I'm lazy. Git status is nice too, again you can do it in bash but not out of the box. So I can install it in one line and get on with my life or spend ages editing my .bashrc for the functionality I want. It's a no-brainer.

/thread

>no sudo !!
kys

Powershell

Krebs pls

more like Verbosehell amirite

I use zsh just because it's the default shell my works dev boxes are setup with. I don't think they have it all that customized though.

I've never bothered to rice it because I don't end up doing that much command line scripting. I would like to get a little more familiar with it though does any one have any suggestions for good tutorials or lessons? There's probably inefficiencies in my current workflows that I could solve with strong shell scripting.

OP here. Thanks for thorough explanation.

yes bash can do that
man bash

Since always.
ksh93 -o vi
The other options, other than vi, are gmacs and emacs.