Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made my command prompt ($PS1) to be just username.../current_directory (using the 3 dots because my directory structure has lots of levels and they were taking up too much of the command line prompt).
However this would work better if, when I cd'd into a directory, the cd command showed what directory I get changed into. How can I have this happen?

btw my command prompt setting (that I don't wish to change) to do username...current_dir is:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u.../${PWD##*/}\$ '
share|improve this question
up vote 10 down vote accepted

With zsh

chpwd() pwd

Then, the current directory is printed whenever it changes (upon cd, pushd, popd...).

With ksh, bash or zsh:

cd() {
  builtin cd "$@" && pwd

(you'd typically put those in your shell configuration file)

share|improve this answer
Another tip you may want to add: in bash, setting CDPATH=. is another method to achieve what the OP wants. – jw013 Nov 14 '12 at 14:52
@jw013, nice trick about CDPATH, however that doesn't output the path for cd /absolute/path (which is probably what the OP wants) or cd ./foo or cd .. or cd ../bar – Stéphane Chazelas Nov 14 '12 at 15:05
That is true. It is enough to cover 99% of the cases for me. I rarely need to see the full path if I am already using an absolute path argument to cd, and when I use ./ or .. I generally already know where I am. – jw013 Nov 14 '12 at 15:10
Accepted, works great (bash). – Michael Durrant Nov 14 '12 at 16:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.