Bash or-equals ||= like Ruby
You can set your prompt to be the working directory with this:
PS1='\w ' # Using \W will provide just basename
Another solution (which is more akin to Ruby's or-equals in my opinion) would be:
[ -n $PWD ] || PWD=`pwd`
Bash allows for default values:
a=${b-`pwd`}
If $b
is undefined, then pwd
is used instead in assigning $a
.