My terminal has a default prompt format like this one:
username@boxname /path/to/current/directory $
The code that produces it looks like this: (it has some color definitions too)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'
If the path to the current directory gets too long it becomes unpleasant to work with the terminal because you constantly break lines. In such cases I would prefer a format that produces a shorter string like this one:
username@boxname current_dir_name $
The code that produces it would look like this (again with color):
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] $(basename ${PWD}) \$ \[\033[00m\]'
Does anyone know how I could easily toggle the format of the current terminal window from one style to the other by just typing for example: prompttoggle?


PROMPT_DIRTRIM=0andPROMPT_DIRTRIM=1seems simpler than toggling between different values forPS1and the result is almost the same. Thanks for the info! – Rotareti Sep 07 '16 at 23:41PROMPT_DIRTRIMone could also add arguments to the command. If you pass no argument you toggle betweenPROMPT_DIRTRIM=0andPROMPT_DIRTRIM=1and if you pass a number as an argument you setPROMPT_DIRTRIMto it.promptlenwould be a more appropriate name for the command then. – Rotareti Sep 07 '16 at 23:47