Re:The fish shell is amazing
by Macha on Thursday November 25, 2021 @11:50AM
(#29342821)
Interestingly 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.
[ Parent
| on HN ]
ZSH plus oh-my-zsh cd’ing into a git repo with large LFS files will hang your shell even on very fast NVME storage.
You 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%}"I found that all I really wanted to show was the current branch, which I do with https://gist.github.com/ivan/79de5e87210e8cf21e305bb4c30c436...
You 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