5 ms·
I just started to use fish which seems like most of the things oh-my-zsh does but without the hassle. On the down side it has few quirks (loops, wildcards for e
by StreamBright 4y ago
I just started to use fish which seems like most of the things oh-my-zsh does but without the hassle. On the down side it has few quirks (loops, wildcards for example).
- kstrauser 4y agoI switched to fish a couple of years ago and I'd never go back now. Want to customize your prompt? Write a function called "fish_prompt" that calls git, echo, or whatever else you want and make them write to stdout. There, done. Want to add a second prompt column to the right side of your shell? My "fish_right_prompt" function looks like set_color 666666 date +'%Y-%m-%d %H:%M:%S' set_color normal and it puts the date at the end of each command prompt. Have spaces in filenames? Watch this: $ touch a "b c" d $ for i in *; echo "<$i>"; end <a> <b c> <d> Of course it handles that for you automatically. The downsides are that it's not POSIX-compatible, that command lines you find online may or may not work in it, and it's not going to be installed on every machine you touch. However, 1) you can still use bash or zsh if you occasionally need to, and 2) why make your life harder if you're using a machine you can install software on 99% of the time? I mean, I still write Python, even though it's not installed everywhere by default.
- eddyg 4y agoFWIW, zsh can do that stuff (and more!); e.g. set RPROMPT for a "right prompt". It also handles files with spaces just fine: $ touch a "b c" d $ for i in *; { echo "<$i>" } <a> <b c> <d> Once I added 'zsh-syntax-highlighting' and 'zsh-autosuggestions' I didn't see a reason to deal with all the eccentricities of a non-standard shell like fish. (If anybody is looking for a terrific "turn-key" zsh config that is fast, check out https://github.com/romkatv/zsh4humans/tree/v4 https://github.com/romkatv/zsh4humans/tree/v4 ... there are instructions for trying it out in Docker so it won't mess with your existing shell config.)
- kstrauser 4y agoYes, but here's what zsh's prompt setting looks like: https://zsh.sourceforge.io/Intro/intro_14.html https://zsh.sourceforge.io/Intro/intro_14.html In fish, it's literally just a function that runs normal commands. There's no special syntax or anything. And in any event, that's just an example. Fish feels like it was built to be ergonomic and convenient. It's also lightning fast because all of the nice things are built-in and don't have to be accreted around it.
- soraminazuki 4y agoIn other words, zsh uses format strings. You don't need to use the format specifiers, it's just there for convenience so that you won't need to spawn a bunch of processes to do trivial stuff. Here's one example that is very much ergonomic and convenient as the fish way: setopt prompt_subst PROMPT='$(whoami)@$(hostname): $(pwd) \$ ' Things don't have to be "accreted around" in zsh either. It has a powerful completion system, convenience commands and keybindings built into it. It can do pretty much what people want from fish sans the syntax. It's just that there are an abundance of plugins and frameworks around zsh because it was designed to be extensible from the ground up. Some of those frameworks do slow down the shell, but that's a problem with that particular framework, not inherent to how zsh works.
- kstrauser 4y agoI highly recommend installing Fish and experimenting with it for a couple of days, if only to see what a different approach to shell design looks like. Don’t try to make it into a Zsh clone, but use it as itself and see what you think. If you do that, I suspect you won’t find that prompt_subst is a good replacement for being able to write full-blown functions that allow complex flow logic like “if logged in as root…” or “if this is a Git directory…” or “if the last command succeeded…”. Yes, you can do all of those in Zsh in the sense that both shells are Turing complete, but wow, it’s nice when the shell makes it easy and fun to do these things.
- soraminazuki 4y ago
- Calzifer 4y agoSpaces in filenames is more a Bash problem. Zsh does far less automatic word splitting. > Note in particular the fact that words of unquoted parameters are not automatically split on whitespace unless the option SH_WORD_SPLIT is set; see references to this option below for more details. This is an important difference from other shells. https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parame... The example works the same in Zsh. (of cause with the slightly different for loop syntax) for i in *; do echo "<$i>"; done
- StreamBright 4y agoYes, this is exactly it. Btw. POSIX is grossly overrated. There are many things that could have done better.