Beast_Code
Beast_Code

Reputation: 3247

How do I permanently change the terminal prompt in iTerm2 using zsh?

In the terminal prompt under the Default profile this shows:

Last login: Sat Jun 21 17:43:00 on ttys000
➜  ~

When I type:

➜  ~  export PS1="|%*| ~ "

I receive this:

|17:44:11| ~

That's what I want displayed. How do i make this permanent, so I won't have to type this every time?

I have tried the following: inserting export PS1="|%*| ~ " into .zsh, also under Prefrences >> Profile >> CustomeTheme and Default >> Command >> checked command I inserted export PS1="|%*| ~ " with no luck.

Upvotes: 1

Views: 5975

Answers (1)

Keith Thompson
Keith Thompson

Reputation: 263237

This has nothing to do with iTerm2; it's purely a zsh issue.

You need to add the command

PS1="|%*| ~ "

to your $HOME/.zshrc file.

Followup based on the comments: Your best bet is to add this line at or near the end of your .zshrc file. If something else in .zshrc is settings $PS, either directly or indirectly (by invoking another script), you want your desired value to override that.

There's no need to export the value of $PS1.

There are probably other places you could put the command. See the zsh manual (or type info zsh) for more details. As far as I can tell, zsh doesn't pay attention to a .zsh file (unless you specifically tell it to).

Upvotes: 2

Related Questions