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.
In 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:
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.
I 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.
You can write full-blown functions for displaying prompts just as easily.
prompt_custom() {
if (( EUID == 0 )); then
printf '# '
else
printf '$ '
fi
}
setopt prompt_subst
PROMPT='$(prompt_custom)'
or more commonly,
prompt_custom_precmd() {
if (( EUID == 0 )); then
PROMPT='# '
else
PROMPT='$ '
fi
}
add-zsh-hook precmd prompt_custom_precmd
I do occasionally check the fish repo for status updates, but decide not to make the switch because of syntax incompatibility concerns and lagging vi keybinding support. Those are issues that I would encounter on a daily basis if I were to use fish.
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.