User Tools

Site Tools


bash Resources

bash variables


List names, values and types of all variables

Useful on the command line, to see what you're working with:

declare -p

bash command prompt customization


Show cwd basename, not entire absolute path

First, back up the copy of .bashrc that came with Ubuntu:

anthony@anthony-VirtualBox:~$ cp -p .bashrc .bashrc.orig

Changed \w (absolute path, I think) to \W (“basename”, just the single directory name):

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# orig. line:
#    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# adc changed 2016.01.27:
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '

Based on advice from:

resources/bash_resources.txt · Last modified: 2019/05/22 16:08 (external edit)