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?
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.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With