Dup Goto 📝

.zshrc stuff

PT2/linux/setup-notes linux zsh 04-07 16:08:22
To Pop
45 lines, 198 words, 1589 chars Sunday 2024-04-07 16:08:22

My first choice shell is still bash, but since macos uses zsh I'm starting to learn that. There's a lot good about zsh, but not enough compelling to entice me to switch.

Edit with vim like bash

In bash, one can press C-x C-e to edit the command line in your chosen editor. To get the same in zsh, use

autoload -z edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line

Oh My

There is Oh My Zsh which is interesting. Alas zsh doesn't have an equivalent of --rcfile to start with an alternative rc file.

This is one place where I tend to set up a spare user account to install stuff to first and test out before migrating settings to my main user account.

Install via

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

or

sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

My Prompt

This is based on the robbyrussell theme, but uses a blank line to separate from output above, and has a fuller status line above the prompt.

# based on robbyrussell
PROMPT="
zsh %(?:%{$fg_bold[green]%}%1{%}:%{$fg_bold[red]%}%1{%})(%?) %{$reset_color%}%{$fg[white]%}%D %* %{$fg_bold[green]%}%n@%m:%{$fg_bold[blue]%}%0d%{$reset_color%}
%{$fg[cyan]%}%c%{$reset_color%}"
PROMPT+=' $(git_prompt_info) %# '

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}%1{✗%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"