Add newline to Oh My ZSH Theme

Andrew Connell picture Andrew Connell · Dec 7, 2016 · Viewed 11.2k times · Source

I'm trying to add a newline to my existing Oh My ZSH theme but can't figure out what to add or where it should be added / changed. Any ideas?

Answer

gvsrepins picture gvsrepins · Apr 15, 2017

I was actually searching for the same answer. But my needs was a little more specific since I only wanted to add a newline in the agnoster theme, the one I'm using now.

In my research, I find a lot of forked themes that already do it, but I thought that this was an overkill solution for only add a new line.

So I read the agnoster code and come up with this simple solution of overwrite the prompt_end() function in my .zshrc file.

To do it, just add the code bellow in your .zshrc file:

prompt_end() {
  if [[ -n $CURRENT_BG ]]; then
      print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
  else
      print -n "%{%k%}"
  fi

  print -n "%{%f%}"
  CURRENT_BG='' 

  #Adds the new line and ➜ as the start character.
  printf "\n ➜";
}

Hope it helps you to have a clue on how to customize your chosen theme.

Here is the result:

enter image description here