From 7fabf88041d4594b6ddeb4b22323c66677e31c3e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 12 Aug 2010 09:36:11 -0400 Subject: [bashrc] Show parent dir in prompt too for context --- dotfiles/bashrc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dotfiles/bashrc b/dotfiles/bashrc index a9ab53c..5077eca 100644 --- a/dotfiles/bashrc +++ b/dotfiles/bashrc @@ -16,6 +16,23 @@ shopt -s histappend EDITOR="emacsclient" export EDITOR +_format_wd () +{ + pwd=$(pwd) + base=$(basename $pwd) + parent=$(basename $(dirname $pwd)) + pparent=$(basename $(dirname $parent)) + if test pparent != "/"; then + echo "$parent/$base" + else + if test parent != "/"; then + echo "/$parent/base" + else + echo "/$base" + fi + fi +} + _format_inroot_dir () { if test -z "$INROOT_DIR" && test -n "$CERTIFIED_GNOMIE"; then @@ -34,7 +51,7 @@ _format_uid () fi } -PS1_PREFIX='\W$(_format_uid)$(_format_inroot_dir)' +PS1_PREFIX='$(_format_wd)$(_format_uid)$(_format_inroot_dir)' if test -n "$BASH_COMPLETION" && test -f /etc/bash_completion.d/git; then PS1_PREFIX="$PS1_PREFIX"'$(__git_ps1 " [git %s]")' fi -- cgit