This question already has an answer here:

I am using gnome-terminal. I often work on large projects where there are lots of sub-directories and I have to compile them from the terminal. It's a very problematic to work with long-path terminal prompt while you have one monitor.

Assume you are in a directory,


Now while I am using the terminal, is there any tricks or shortcuts to make the current address to a dummy string or text so that it may easy to work. Like if I want to show the above address as,


where proj1 = /sys/dev/block/7:6/bdi/subsystem/7:7/power. I want do it on the go. like while I am using the terminal can I do it in a short amount of work.

marked as duplicate by muru command-line Dec 20 '17 at 3:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can add this feature to your shell by modifying your ~/.bashrc file.

Assuming a standard configuration, in your ~/.bashrc file change the definition of PS1, which is the prompt, from:

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@\h:\w\$ '

to the following:

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

You are replacing both the \ws with ${PROMPT:-\w}.

In a prompt string, the \w means the current directory. The ${VAR:-VALUE} means use VALUE unless the variable VAR is set and not null. Therefore it is possible to override showing the current directory while a shell variable is set.

Now you can set the alias with:

sbmaruf@lenovo:/sys/dev/block/7:6/bdi/subsystem/7:7/power$ PROMPT=proj1

And unset it with:

sbmaruf@lenovo:proj1$ unset PROMPT

Or set it as null:

sbmaruf@lenovo:proj1$ PROMPT=
  • For clarity, you might want to use a more descriptive variable name, like OVERRIDE_PROMPT_WD or something. – wjandrea Dec 20 '17 at 2:18
  • @Martin Thornton : I'm now using powerline shell now. github.com/b-ryan/powerline-shell#customization Is there any way to customize now. – Maruf Jan 10 '18 at 14:53

If your prompt uses pwd you can define a symbolic link e.g. in your home directory: ln -s /sys/dev/block/7:6/bdi/subsystem/7:7/power ~/proj1.

Then cd ~/proj1 and your prompt should become (almost) what you want i.e. sbmaruf@lenovo:~/proj1$

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