4 ms·
Moving to zsh (2019)
- morekozhambu 4y ago
- Maursault 4y agoGood stuff, but, conversely, one may just manually set any user's default shell [1] back to bash, or Bourne, ksh, csh, tcsh, or install and use another as a default shell, such as fish, nsh, nushell, rc, yash, etsh, and so on and so forth. [1] https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/ https://www.howtogeek.com/444596/how-to-change-the-default-s...
- Fnoord 4y agoI prefer Fish. And with xxh (or Nix) you can take it with you to a ssh session near you. There is also a couple of plugins in OMF and Fisher to fix some bashisms Fish is missing.
- mattpallissard 4y agoI'm a zsh user, but one thing I miss from bash is /dev/tcp redirection. ~ echo <>/dev/tcp/google.com/80 ~ echo $? 0 ~ echo <>/dev/tcp/localhost/80 bash: connect: Network is unreachable bash: /dev/tcp/localhost/80: Network is unreachable ~ echo $? 1
- softjobs 4y agoWhat about https://zsh.sourceforge.io/Doc/Release/TCP-Function-System.html https://zsh.sourceforge.io/Doc/Release/TCP-Function-System.h...?
- tambourine_man 4y agoI think that’s Linux-only, right?
- ccouzens 4y agoIt's in the /dev/ folder so it looks like a device file provided by the operating system. But it's not. It's a bash built in pseudo file. So it should work in bash on other operating systems.
- hericium 4y agoNice thing to learn - thanks. Although the only scenario I can think of at the moment would be the lack of netcat (and telnet). Not a fan of limiting scripts with bashisms. I like them to be runnable under zsh and similar shells despite having /usr/bin/env bash, /bin/bash, /bin/sh shebang.
- ebfe1 4y agoA more sneaky use case is for reverse shell payload when you have code execution :)
- tambourine_man 4y agoYou're right, it does work on macOS. What other cool use cases could it achieve besides checking if a domain is reachable?
- runjake 4y agoWhy? There’s nc.
- sph 4y agoI tend to prefer telnet to test connections because its output is more verbose. We need a friendlier netcat, with better output. Call it netdog.
- runjake 4y agonc generally provides more verbosity with -v and other options. nc -v itself is pretty much telnet as far as TCP connections go (TELNET is itself another protocol on top of TCP). In fact on macOS, I alias telnet=’nc -v’. Anyway my intent wasn’t to directly challenge your method, this is just a more shell-independent and universal method of doing the same.
- tux2bsd 4y agoThanks. I've not seen that before, that's cool.
- LeoPanthera 4y agoI've been using bash since the early 90s and I'm now in my 40s so I think at this point I just have to accept that I will never use another shell. On Macs, the current version of bash can be installed from Homebrew and you can set it as your default shell in the SysPrefs, in Users > Right-click you > Advanced
- homulilly 4y agoThis still presents an issue with shebang lines, though. I use ‘#!/usr/bin/env bash’ to work around this but occasionally have to modify other peoples scripts if they’re relying on newer bash features.
- thebitstick 4y agoFirst thing I do for any *nix install is immediately install Fish. Like many younger computer users I prefer rainbow barf.
- plandis 4y agoYeah, I switched to fish about 1.5yrs ago and for me it’s defaults are way better, fish script is way more readable and it’s really easy to customize.
- noisy_boy 4y agoI tried fish and really liked it until I tried to run one of my numerous helper scripts and was faced with syntax error; too lazy to update so many scripts.
- saila 4y agoDid you try "bash <script>" or adding a #! line, which scripts should generally have anyway?
- flohofwoe 4y agoNot the op, but that only worked half of the time when running install scripts from the internet. To make it really work you basically had to setup and maintain a full bash environment in parallel to the fish environment (env variables, paths, etc...). Most software packages out there really expect that you're running in a bash-compatible environment.
- abdusco 4y agoI launch a bash shell, which inherits parent fish shell's env, then run the command and exit back to fish.
- noisy_boy 4y agoAll my scripts have "#!/usr/bin/env bash" at the top but in some cases that didn't help. Also, I think some bash specific bits in my .bashrc had syntax errors. Eventually I just didn't want to deal with the hassle of switching over.
- celowsky 4y agoBash can do everything zsh can. You just need to know it well enough. There isn't any reason to change default shells to zsh except for licensing concerns by closed-source minded companies.
- dmd 4y agoOf course it can. And a sufficiently large enough piece of paper and a well-sharpened pencil can do anything a computer can, but I suspect most people will choose to go on using computers.
- hyperhopper 4y ago"Assembly can do everything c++ can. You just need to know it well enough."
- allurbase 4y agoWhy is zsh forced on users anyway? Are there known issues with bash? I’m sure there are - anyone have a link?
- neilparikh 4y agoI believe it was because Bash 4 switched to GPL3, which Apple did not want to follow. See https://www.theverge.com/2019/6/4/18651872/apple-macos-catalina-zsh-bash-shell-replacement-features https://www.theverge.com/2019/6/4/18651872/apple-macos-catal...
- hericium 4y ago> Why is zsh forced on users anyway? Are there known issues with bash? ZSH isn't GPL which may be important in the smaller non-Linux part of UNIX-like world. I would very much like to see ZSH in FreeBSD's base system already. BTW, forced how?
- cyberpunk 4y agoThere was a MacOS update that set everyone’s shell to zsh instead of the default (ancient) bash. Hardly insurmountable, but the change was a “forced” part of the upgrade.
- hericium 4y agoChanging users' default shell is not the same as forcing it on users. You can chpass(1) and set a different shell. I'm not too comfortable playing devil's advocate here as Apple really does force shitty changes on users. But this isn't one of those cases.
- Fnoord 4y agoThe article mentions it is because Bash went to GPLv3 and Zsh is MIT, and Apple is (my words) allergic to GPLv3. They avoid it everywhere. (Which tells me its a fantastic license.)
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- fmakunbound 4y agoOf course you don’t have to switch, since you can brew install bash 5 or whatever the latest is and then chsh to it, but if you want to use it as an opportunity to change shells, consider checking out some of the newer interactive shells like nushell, elvish, xonsh, oil etc. Some of them are even based on actual general purpose, fairly common programming languages.
- srik 4y agoI really want to try something new but many of those shells are not POSIX compliant enough to be a daily driver and that's kind of a deal breaker. I often run external shell scripts to install various things and the fear that the new shell environment might muck up something I didn't notice is too real. Would have otherwsie moved to fish long ago, so for now it looks like zsh is as good as it gets (unless my concerns are unfounded of course).
- 0xCMP 4y agoI don't actually think it's that big of an issue. Most of those kinds of scripts should have something like `#!/bin/sh` already to ensure they can be run everywhere and you could always run a specific script in bash/zsh if needed. Worst case, really, is that many of them do $PATH manipulation, set Env variables for you, or setup autocomplete and you'll need to redo that work in your shell of choice if it doesn't act like bash/zsh (e.g. I think nushell would be the most annoying in this way).
- 0xCMP 4y agoA huge reason for my personal time investment in Nix has been to be able to ignore problems like this. I don't want to constantly fear that as I've finally decided to put effort into making things nice for myself for things to change without any recourse.
- cmckn 4y agoLuckily, chsh.
- remuskaos 4y agoI've switched from bash to zsh a few weeks ago and overall, I'm pretty happy. Menu based auto completion for example is extremely nice. But I could never get auto complete for rsync to work. I have some hosts in ~/.ssh/config (think "Hostname prod01" etc) , and in bash auto complete works for ssh, scp and rsnyc ("rsync prod01:someFile .") In zsh, this only works for scp and ssh, but not rsync, and I haven't found a way to make this work. Does anyone know how to get it to work like in bash?
- idoubtit 4y agoI don't have a magical solution since you didn't give much context. I suppose that completion is enabled (compinit, complist) and generally working since you mentioned it for ssh & scp. Maybe you're just lacking the file that contains the completion instructions for rsync. It should be named "_rsync". In my case, Debian's "zsh-common" installs it in "/usr/share/zsh/functions/Completion/Unix/_rsync".
- remuskaos 4y agoThat's a good idea, thank you! I simply installed zsh over the package manager, autocomplete seems to work other than rsync. I'll look into it when I get back to the computer and report back.
- wodenokoto 4y agoI like zsh and it’s my choice of shell. But at the same time I feel it’s too close to bash. I can still run bash scripts, so why does everything at the command line have to be almost, but not quite bash? I think it would be nice with a bit more of a paradigm switch that could open up for some new interactive possibilities. But bash alternatives seems to be mostly a better version of bash for some definition of better.