Is it possible to show in the terminal line only the current directory, not the whole path from the home folder?

I have now this: ilya@ubuntu:~/Dropbox/Web/folder/folder/$ and it takes almost all the screen...

up vote 21 down vote accepted

The part before the $ in a shell is called prompt. It can be configured by changing the variable $PS1. There are is a similar question with good answeres.

The man page (see "Bash" and there "PROMPTING") says:

      \w     the  current working directory, with $HOME
             abbreviated with a tilde (uses the value of the
             PROMPT_DIRTRIM variable)
      \W     the basename of the current working directory,
             with $HOME abbreviated with a tilde

So you have to change \w to \W. Probably the initial value for $PS1 is stored in your .bashrc, that means you have to edit the file ~/.bashrc and you will find lines similar to:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

Change \w to \W in both lines and open a new terminal (or run source ~/.bashrc).

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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