[SOLVED]How to show the current working dir next to my username in terminal?

So my terminal is esmailelbob% and i wanted to make it looks like debian terminal where you see your current working dir (or pwd) so is there a way to do this? to be like esmailelbob - /home% or something near to it


SOVLED:

You can place this to your .zshrc file

export PS1="%d %% "

%d denotes the CWD

For more details go here for example

Source: https://stackoverflow.com/a/25090332


If you are really curios:

Sequence	Printed
%T	System time (HH:MM).
%*	System time (HH:MM:SS).
%D	System date (YY-MM-DD).
%n	Current username.
%B - %b	Begin - end bold print.
%U - %u	Begin - end underlining.
%d	The current working directory.
%~	The current working directory, relative to the home directory.
%M	The computer's hostname.
%m	The computer's hostname (truncated before the first period).
%l	The current tty.

~ https://wiki.gentoo.org/wiki/Zsh/Guide#Prompts

3 Likes

Just in case @megavolt’s reply is “tl;dr”, add this to your ~/.zshrc ─ your interactive shell appears to be zsh. :arrow_down:

export PS1="\u - \$PWD \$ "

:slight_smile:

1 Like

After some googling I just changed /W to /w on lines 73 and 75 in my ~/.bashrc file and that did what I wanted it to do.

kev.

1 Like

i dont have ~/.zshrc ? thats weird (im new to arch)

and i tried it but it looked like

esmailelbob% export PS1="\u - \$PWD \$ "

\u - $PWD $ 

i use GNOME Terminal

The percent sign (%) at the end of a prompt is typical for zsh and csh (or variants thereof), while for bash, ksh (and variants) and dash, it would normally be a dollar sign ($). That’s why I was assuming you were using zsh.

echo $SHELL

… will tell you what shell you’re using. If it’s bash, then just add the command to your ~/.bashrc. :wink:

why i feel weird :joy:

esmailelbob% echo $SHELL
/bin/zsh
esmailelbob% cat ~/.zshrc
cat: /home/esmailelbob/.zshrc: No such file or directory
esmailelbob% cat ~/.bashrc
cat: /home/esmailelbob/.bashrc: No such file or directory
esmailelbob% 

So you do have zsh, even though you don’t appear to have any user-level configuration file(s) for it. But unfortunately, I don’t have any experience with zsh, so all I can recommend is to read the manual… :man_shrugging:

man zsh
1 Like

i created the file and it seems it catches it. but still my problem with the \u - $PWD $ when i write your code

That’s why you need to read the manual. The shorthand codes for the information shown in the prompt might be different between zsh and bash. :wink:

Try this instead… :arrow_down:

export PS1="%u - %PWD %% "

You can find the manual here: :arrow_down:

zsh: Table of Contents

1 Like

I hate reading, lol. but your replies helped me to at least know which bash i got so thanks and this worked: https://stackoverflow.com/a/25090332

1 Like