Show only current directory name (not full path) on bash prompt
Problem
The way my bash prompt is currently configured, it shows the whole path to the current directory. This is annoying when I'm deep inside a directory tree, as the prompt becomes so long that every command wraps into the next line. How do I make it show only the last part of the path? This is what I have in my :
Error Output
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esacUnverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: Show only current directory name (not full path) on bash prompt
Change the (lowercase) to (uppercase): Have a look at the Bash Prompt HOWTO for lots of fun details. example: The variable, if set, is a command that gets run before displaying the prompt specified in . In your case, runs an statement with certain ANSI escape sequences that manipulate the titlebar of an Xterm. If you suspect your is overriding your prompt, you can it and test things out: Finally, be sure that you're changing the definition that actually gets used. Common locations are , , , , .…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix