How to set prompt in tcsh and bash

Wherever I go, I like to set prompt to display the current directory. I mean the complete path of current directory, not just the last element, and they all must be in one single line.

This is good:

/usr/bin/X11 >
Avoid this:

bash-3.2$ cd /usr/bin/X11
localhost$ cd /usr/bin
localhost$ /usr/bin
For tcsh, I have this in my $HOME/.tcshrc:
set prompt="%/ > "
For bash, include this in $HOME/.bashrc:
PS1="\w > "
, Or you can also run export PS1="\w > " from a bash terminal.

The benefits?

1. I don't need to type pwd 100s times a day. I don't even remember when was the last time I typed pwd.

2. I can easily copy the current working directory and pasted it elsewhere. Notice the trailing space in the value of prompt and PS1? With them I can simply double-click the path to select and copy it.

Tags: , ,