How to you configure the command prompt in Linux to show current directory? I want to be able to put settings for this in the .zshrc file.
To print the current working directory, we use the pwd command in the Linux system. pwd (print working directory) – The pwd command is used to display the name of the current working directory in the Linux system using the terminal.
Use the pwd command to write to standard output the full path name of your current directory (from the /(root) directory).
You can place this to your .zshrc
file
export PS1="%d %% "
%d
denotes the CWD
For more details go here for example
I use "%20<...<%~%<<"
in my $PS1
, so that if a prefix is found in the current working directory, it is replaced by ~
: it works with $HOME
(replaced by ~
), home directories of users (replaced by ~user
), and directories defined by hash -d
(e.g., if one has hash -d foo=$HOME/path/to/dir
, then this directory is replaced by ~foo
). The %20<...<
and %<<
allows zsh to truncate the directory on the left side if it is too long, in order to avoid a too long prompt.
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