I'm currently trying to learn more about CLI with my new Macbook Pro M1 and try to customize my promt.
In my home directory it is showing:
johndoe@Johns-MacBook-Pro ~ %
in order to find out more about this prompt, I've typed:
echo $PS1
// output: %n@%m %1~ %#
The variables n and m do not fit the explanation found online: https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/
As they refer to a list of following env variables:
- \h = Hostname
- \u = User name
- \w = Current directory
- \W = Basename of current directory
- \d = Current date
- \n = Newline
- ...
According to these source, this command:
PS1="\u:\w\$ "
should lead to following prompt:
user:working_directory$
It seems the variables have changed and so did the character from \ to %. And unfortunately I can not find any information about the new variables.
Does anybody know more about it or has a link to an explanation?
CodePudding user response:
You're using zsh, not bash. Description of prompt sequences is
explained in zshmisc(1) (type man 1 zshmisc
too see it). For
reference, it says:
%n $USERNAME.
%m The hostname up to the first `.'. An integer may follow the `%'
to specify how many components of the hostname are desired.
With a negative integer, trailing components of the hostname are
shown.
%~ As %d and %/, but if the current working directory starts with
$HOME, that part is replaced by a `~'. Furthermore, if it has a
named directory as its prefix, that part is replaced by a `~'
followed by the name of the directory, but only if the result is
shorter than the full path; see Dynamic and Static named direc‐
tories in zshexpn(1).