Reputation: 51
I am installing dev tools on a new MacBook Air (M1) with Big Sur and the default terminal prompt is too long and includes my user name and host, so I found instructions on how to customize it.
Using the Terminal's preference window, I added this code.
export PS1="\W \$"; clear;
but when I launch the terminal, I get this prompt
\W $
I replaced W with other options, but they are never processed - I just get the literal string.
I suspect it has to do with the config file format for Terminal.
Upvotes: 5
Views: 15290
Reputation: 1336
Create .zshrc
file at user root and paste text. Follow steps mentioned below.
vi ~/.zshrc
i
button in keyboard to enter in edit modeexport PS1="%~ $ "
Esc
button in keyboardShift + :
button in keyboardwq
button in keyboard and press Enter
It Works!
For more configuration check documentation https://zsh.sourceforge.io/Doc/Release/Prompt-Expansion.html
Upvotes: 1
Reputation: 9915
My guess is that the \W
is specific to bash.
Nowadays, the default macOS shell is zsh. See this page for some zsh prompt options
I am unable to test it on my Windows machine, but
PS1="%1~ $"
looks similar to \W
to me.
Of course, if you want to configure your terminal to use bash, that's also an option.
Upvotes: 3
Reputation: 2874
I have something like:
#!/usr/bin/env bash
export BEEP=$(echo -en "\007")
LIGHT_GRAY="\[\033[0;37m\]"
GREEN="\[\033[0;32m\]"
export PS1=$LIGHT_GRAY"\u@\h $GREEN\w : $BEEP"
Works for me to give:
robevans@Robs-Machine ~ : [start_typing_here_in_green]
with an audible sound (not a beep but macOS's 'chime') when a command's execution is complete.
Upvotes: 1