10 ms·
I used fish for a couple of years and really liked it. But I recently learned that I can configure ZSH to have all of the same auto-complete and plugins that I
by jonfw 5y ago
I used fish for a couple of years and really liked it. But I recently learned that I can configure ZSH to have all of the same auto-complete and plugins that I loved from fish. Now I have all of the creature comforts I like, with POSIX compliance
I found that while fish has better syntax than bash for most things, the hassles with incompatibility or unexpected behavior brought me much more trouble than BASH's syntax ever has
- rainingmonkey 5y agoPOSIX compliance has never brought me any issues, if I want bash syntax I just use `bash -c COMMAND`. You can invoke bash scripts with `bash SCRIPT` or just add the bash shebang `#!/bin/bash` to the top of your script, set the executable bit and invoke directly.
- jscheel 5y agoThis is my problem as well. I’ve been using fish for quite a long time, and I’m still frustrated by weird posix incompatibility.
- lovelyviking 5y ago>I’m still frustrated by weird posix incompatibility. Can you also share what are the most significant problems with posix incompatibility for you? Why is it a problem?
- mey 5y agoThe one I see is really, all of Linux vs OSX/MacOS. And which version of Bash is shipped by default. Internally we have a boot strap run book developers/operations to bring up either Windows/WSL or MacOS to a consistent shell env.
- preseinger 5y agoThis shouldn't be an issue! Shell scripts begin with e.g. #!/usr/bin/env bash which means the interactive environment is irrelevant. Users of nonstandard shells like fish need to learn a bit of on-the-fly translation if they expect to copy/paste into their terminals, but it isn't too onerous.
- mey 5y agoNot going to ping my coworker that deals with this (Happy Thanksgiving), but the version shipped with OSX was several versions behind Linux.
- BigJ1211 5y agoI just checked it on my Mac and my Ubuntu server. MacOS has version 3.2.57(1) Ubuntu has version 5.0.17(1) Apparently Apple cites license concerns as the reason for not upgrading it. Don't know how valid that is. License on version 3.2.57 is GPLv2 License on version 5.0.17 is GPLv3+ It's simple enough to update if you use homebrew. `brew install bash` Add the brew version of bash to the /private/etc/shells and change the shell.
- mey 5y agoThat's basically one of the developer setup steps, in addition to running through installing things like jq and yq. Point is, it was a significant enough of a delta (easily fixed) that we ran into compatibility issues with the scripts we wrote.
- jscheel 5y agoHonestly, I think it’s just fighting years of muscle-memory more than anything. Not necessarily a valid complaint, I know.
- dangus 5y agobass can be helpful for some of those posix issues: https://github.com/edc/bass https://github.com/edc/bass Another random tip: python virtualenv generates a activate.fish script that you should use instead of the plain activate script.
- emptysongglass 5y agoBass has never worked for me, in any scenario. I'm curious to see how you use it. I have never successfully been able to feed it any bash script. At this point I suspect I'm either holding it wrong or it is a thing that is invoked as a thing that works without ever being used in earnest.
- Macha 5y agobass works for things you're meant to source. If the script is not meant to be sourced, just run bash yourscript.sh . It basically runs the script in bash, diffs the environment, and applies the environment changes to your outer fish shell. I use it for some internal tools, and previously used it for nvm though I moved from nvm to fnm now which has fish support.
- yourad_io 5y agoHadn't heard of fnm before, thanks. Seems worth checking out.
- dangus 5y agoIf your bash script has a shebang you shouldn’t need bass at all. Fish will read the shebang and just run your script with bash. The only thing I ever used bass for was this edge case where at work the way we login to AWS is using this Okta AWS integration that prints out a list of export commands. Since fish isn’t compatible with bash export commands, I just run that command result through bass, which automatically converts them to the fish set -x commands. If I remember right, I think the reason why the bash script my company made didn’t work is that the export commands that were run in bash weren’t propagated to the underlying fish environment. I was using fish to run a script with a separate shell, so it didn’t affect my environment variables. Or maybe it was because running exec inside a bash script throws you back into fish which then can’t understand the export command. I could have definitely done my own thing with sed/awk instead, but I suck at those tools and someone else already implemented the functionality in bass. bass exec aws_okta_thing_that_prints_export_commands_to_stdout (Off the top of my head, I think it was something like that, could be misremembering! And by this comment you might be able to tell that I’m far from an expert on how everything works.)
- wirthjason 5y agoAny suggestions? I’ve recent switched from vanilla bash to ZSH. I mainly use oh-my-zsh and Power10k. Once again the defaults without much customization.
- anamexis 5y agoI prefer prezto to oh-my-zsh for performance reasons. https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto
- animal_spirits 5y agoMy only plugins are zsh-autosuggestion (https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions) zsh-syntax-highlighting (https://github.com/zsh-users/zsh-syntax-highlighting https://github.com/zsh-users/zsh-syntax-highlighting) and zsh fzf-tab (https://github.com/Aloxaf/fzf-tab https://github.com/Aloxaf/fzf-tab) its been wonderful using these plugins
- Bayart 5y agoSlimzsh[1] is a very nice default configuration. Just a slim prompt, fast-syntax-highlighting and some vanilla settings. I keep a personal fork with a few added plugins (most notably zsh-autosuggestions and ssh-agent). No need for a plugin manager. oh-my-zsh is way too bloated. But it's a nice repo if you're looking for plugins and aliases. [1]: https://github.com/changs/slimzsh https://github.com/changs/slimzsh
- mattgreenrocks 5y agoThe popularity of OMZ with the performance issues and update nags really makes me wonder if people even notice or care about those two things.
- wyclif 5y agoIf you use just a few plugins, it's really not that slow. But if you have a lot more, performance might become a real issue.
- binarysneaker 5y agoCame here to say the same. The default zsh config in Kali has some pretty nice autocompletions, which I've borrowed and use on all my other systems.
- Macha 5y agoInterestingly I moved from such a zsh setup to fish a couple of years back. Zsh with add-ons was noticeably slow compared to fish and syncing the config to all the devices I used.
- ulzeraj 5y agoZSH plus oh-my-zsh cd’ing into a git repo with large LFS files will hang your shell even on very fast NVME storage.
- xondono 5y agoThat’s the git plugin doing it’s thing. You can fix it in config but I admit is an annoying default.
- adrusi 5y agoYou can get reasonable version control integration from zsh without any kind of wild oh-my-zsh config. Most distributed versions of zsh are compiled with vcs_info enabled. autoload -Uz vcs_info zstyle ':vcs_info:*' enable git hg zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:git*' formats "%{$fg[cyan]%}(%{$fg[green]%}%s %{$fg[blue]%}%r%{$fg[cyan]%}:%{$fg[green]%}%b%{$fg[yellow]%}%m%u%c%{$fg[cyan]%})%{$reset_color%} " setopt prompt_subst export PROMPT="%{$fg_bold[red]%}%n%{$reset_color$fg[white]%}@%{$fg_bold[green]%}%m%{$reset_color$fg[white]%}:%{$fg[cyan]%}%1~ \${vcs_info_msg_0_}%{$fg_bold[white]%}%(#.#.\$) %{$reset_color%}"
- ivank 5y agoI found that all I really wanted to show was the current branch, which I do with https://gist.github.com/ivan/79de5e87210e8cf21e305bb4c30c4360#file-zshrc-L217-L239 https://gist.github.com/ivan/79de5e87210e8cf21e305bb4c30c436...
- tekknik 5y agoYou can do this in fish with a direct call to git branch, and it’s not slow and doesn’t require catting files: set -l git_branch (git branch 2>/dev/null | sed -n '/\* /s///p') if test -n "$git_branch" echo -n -s (set_color yellow) "<$git_branch>" (set_color normal) " " end
- dietr1ch 5y agoI moved from bash => zsh => fish. I wanted reasonable features on my shell, and fish was much faster and needed almost no plugins. The fact that I can write a simple for loop without needing to look up how to do it by far beats the POSIX compatibility, if I need it I can still write a bash script, but when using the shell I don't need to recall where semicolons or `do`, brackets (and how many) go.
- macromagnon 5y agoIs it that hard to remember a bash for loop? for i in $(seq 1 10) do echo $i done Then you can just replace new lines with ; if writing a one liner. for i in $(seq 1 10); do echo $i; done I guess it isn't as simple as python for i in range(10): print(i) but it's pretty close aside from the variable binding.
- yesenadam 5y agofor i in {1..10}
- alerighi 5y agoIn zsh you can avoid the do if you have a single instruction: for i in {1..10}; echo $i to me is as clear as the python version. Very compact and useful for one liners.
- shakna 5y agoBash has some subtleties around loops that can be frustrating, like the body of your loop _may_ actually be running in a subshell (common when iterating over a file), making it difficult to extract what you want from it.
- bandie91 5y agoi bet it's the `cat file | while read …` loop what you are referring to, not any loop. but correct me.
- ulam2 5y ago
- GhettoComputers 5y agoI just start scripts in bash for compatibility at the beginning or use scripts that state it, avoid scripting as much as possible, and I spent a lot of wasted time with configuration of zsh to get most of the functionality of fish but never as good. What did you install?
- saagarjha 5y agozsh is not POSIX compliant and never had a goal of being POSIX compliant. (Amusingly, I use bash and I can pretty much replace “zsh” in your claim with “bash” and have it apply to my usage-except in this case it would be true :P)
- ch_123 5y agozsh has a POSIX compatibility mode, but it is not enabled by default. (You can see some details in the release notes: https://zsh.sourceforge.io/releases.html https://zsh.sourceforge.io/releases.html)
- mattgreenrocks 5y agoThe best reason to choose fish over zsh is that everything works so well out of the box that you stop messing with it. I haven’t tweaked my shell config in 7 or 8 months now. This is a different mindset from the giant zsh configs, “plugin managers” and other junk that is wholly irrelevant to using the shell. You’d think that fish incorporating a lot of functionality that zsh has would manifest as bloating fish, but, IMO the reality is that zsh’s “bloat” is pushed into user configuration and the user is tasked with making it work.
- NavinF 5y agoAnother issue with zsh plugins is that they are incredibly slow. Oh-my-zsh makes every terminal feel like it’s running on another machine over ssh
- RMPR 5y agoAnd that delay when it updates itself is just the worst
- pmarreck 5y agoI thought there was something in, like, Powerman10k or something, which managed to avoid that issue?
- kekebo 5y agoYou probably mean powerlevel10k[0], although that's mostly a replacement of powerlevel9k, which is only one of the (theming) plugins that oh-my-zsh commonly handles. As for a replacement for oh-my-zsh itself, I had good experiences with zgen[1] but the fastest I've found is zim-fw[2] which produces acceptable start times for me[3]. [0] https://github.com/romkatv/powerlevel10k/ https://github.com/romkatv/powerlevel10k/ [1] https://github.com/tarjoilija/zgen https://github.com/tarjoilija/zgen [2] https://github.com/zimfw/zimfw/ https://github.com/zimfw/zimfw/ [3] https://i.imgur.com/mPPQuyh.png https://i.imgur.com/mPPQuyh.png
- smohare 5y agoThis is the framework, not the plugins.
- ayushnix 5y agoI don't get why people expect POSIX compliance from fish. Your interactive shell and your scripting shell can be, should be, and often are, different. I use bash as my default user shell, fish as the default shell of my terminal emulator, and I write scripts for both POSIX sh (dash and busybox ash) and bash. I end up using three different shells with different purposes. Sure, I could use zsh both as an interactive and scripting shell but I don't have the time or willingness to configure it when fish offers a nice out of the box experience. Not to mention that zsh shouldn't be used as a scripting shell in the first place.
- pxc 5y ago> Not to mention that zsh shouldn't be used as a scripting shell in the first place. Why not? If I'm writing scripts for automating configuration on modern macOS, for example, where ZSH is installed by default, why not write ZSH scripts?
- R0b0t1 5y agoIt's more "why not write scripts?" Actually making use of a shell's control structures is code smell until we have far better shells than we currently do. They're optimized for user interaction, not necessarily anything else.
- pxc 5y agoIf you're gonna be calling a lot of external programs and interacting with files a lot, non-shell scripting languages tend to feel pretty clunky. I know what you mean, though. Most shell languages don't feel like flexible, expressive programming languages in the way that they ought to and could. As you may know, there are some new shells/languages that are trying to bridge the gap in a way that still leaves the shell well-suited to interactive use. The Oil shell wiki has a great list of them (and Oil is one such shell itself, of course): https://github.com/oilshell/oil/wiki/Alternative-Shells https://github.com/oilshell/oil/wiki/Alternative-Shells
- 5y ago
- deleted 5y ago[deleted]
- bamboozled 5y agoSame, I used oh-my-zsh, I mucked around and didn't use it for some years, but since re-installing it, I have to say it's one of the most useful and reliable software packages I know of. I kind of forgot that even use it until I read your comment :)
- progforlyfe 5y agoSadly this is the exact reason I switched away from it. I couldn't copy/paste in commands from coworkers or use common web projects (I'd have to either search for a fish replacement or convert it myself... Or just launch bash/zsh). Really nice shell though, I hope it gets more traction.
- max_ 5y agoIt is understated how powerful and ergonomic ZSH is. I hated Apple, but my opinion changed when I learned how to configure ZSH.