Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to you configure the command prompt in Linux to show current directory?

Tags:

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.

like image 797
xarzu Avatar asked Aug 01 '14 23:08

xarzu


People also ask

How do I display the current working directory in Linux?

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.

What is the command to display the current directory?

Use the pwd command to write to standard output the full path name of your current directory (from the /(root) directory).


2 Answers

You can place this to your .zshrc file

export PS1="%d %% "

%d denotes the CWD

For more details go here for example

like image 162
Jiri Kremser Avatar answered Oct 01 '22 22:10

Jiri Kremser


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.

like image 20
vinc17 Avatar answered Oct 01 '22 23:10

vinc17