Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add newline to Oh My ZSH Theme

Tags:

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?

like image 596
Andrew Connell Avatar asked Dec 07 '16 12:12

Andrew Connell


People also ask

Where are ZSH themes stored?

All ZSH-THEME files are stored in Oh My Zsh's themes directory (located at ~/​. oh-my-zsh/​themes). Zsh is a Unix shell and command language that was created by Paul Falstad in 1990. It is very similar to the Bash shell.


2 Answers

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

like image 135
gvsrepins Avatar answered Sep 21 '22 15:09

gvsrepins


Here is my version which works just like the others, but repeats the last symbol of the previous line so that it imitates the exact prompt that agnoster gives you:

prompt_end() {   if [[ -n $CURRENT_BG ]]; then     echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"   else     echo -n "%{%k%}"   fi   echo -n "\n%{%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{%f%}"   CURRENT_BG='' } 

Note: If you do not want to modify the library's source code, you can also just put this function into your ~/.zshrc file near the end. It will then be used over the library-provided function.

enter image description here

like image 37
Felix Dombek Avatar answered Sep 20 '22 15:09

Felix Dombek