Table of Contents

zsh shell custom prompt

Why

Why would you not want to use oh-my-zsh when using zsh shell, there are a lot of themes and features that you can use.

Because it's slow if all you want to use it for is adding a theme to make it look nice, if you are not taking advantage of all the plugins or using one the heavily custom themes, there is no real reason to use it. It looks nice and you don't have to put a lot of work into it, or even try to understand how to create your own. But when it starts to take several seconds for a new shell to start showing up and its all around slow when you need to work with it there is no reason to use it.

So I have made a small custom prompt that is easy to modify if you want, or just use and there is no “performance hit” with slow spawning shell's or lag

Here is a repo link where the shell can be found

https://git.nopants.dk/tobias/ZSH-SHELL

.zshrc without git branch

Here is all you need to add to your .zshrc to use the prompt if you don't want to see a git branch

HISTFILE=~/.zsh_history
HISTFILESIZE=10000
HISTSIZE=10000

PROMPT='%F{051}%n@%M%f in %F{120}%~%f ~> '

if you want syntax highlighting because its usefull, and maybe are like me and make a lot of typo's you can install it with

sudo dnf install zsh-syntax-highlighting

and then add the line below to the last line of your .zshrc

source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

.zshrc with git branch

If you find yourself working with git and want to know your branch by looking at your sell prompt add this to your .zshrc

HISTFILE=~/.zsh_history
HISTFILESIZE=10000
HISTSIZE=10000


function git_branch_name()
{
  branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
  if [[ $branch == "" ]];
  then
    :
  else
    echo '- ('$branch')'
  fi
}

# Enable substitution in the prompt.
setopt prompt_subst

PROMPT='%F{051}%n@%M%f in %F{120}%~%f ~> %F{050}$(git_branch_name)%f '

And as with the section above, if you want syntax highlighting follow the steps above.

GLHF with using the prompt and customizing it to your best liking