Search code examples
linuxzshzshrc

How to configure .zshrc file to have command and path in different lines


I'm using ZSH and wondering if there's a config I can add to my .zshrc file that can separate the command line and path line.

Before:

localhost /workplace/sudo/myservice/src/myservice % [cursor here]

Expecting:

localhost /workplace/sudo/myservice/src/myservice % 
[cursor here]

I know Oh My Zsh can do that but just wondering which exact config was implemented to achieve this?


Solution

  • Just insert a literal line break.

    Before:

    PS1='%m %~ %# '
    

    After:

    PS1='%m %~ %#
     '
    

    Done.

    Alternatively, you can use a $'' string, which lets you use print escape characters, such as \n for newline:

    PS1=$'%m %~ %#\n '