]> git.phdru.name Git - dotfiles.git/blobdiff - .shellrc
bash: Use custom `short_curdir` instead of `\W` in `PS1`
[dotfiles.git] / .shellrc
index 5b1e1d3db39e784807906f1446974f0824843281..541417a422ae2ff1c5040e1e58c70f74b8867034 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -15,6 +15,8 @@ esac
 # Stop if non-interactive shell
 [ -z "$PS1" ] && return
 
+PS1="$OPS1$SHLVL "
+
 if test -n "$BASH_VERSION"; then
    # append to the history file, don't overwrite it
    shopt -s histappend
@@ -58,16 +60,6 @@ case "$HOME" in
 esac
 
 
-# Remove trainling \$s
-OPS1="`echo $OPS1 | sed 's/[ \\$]\+$//'`"
-# Add a trainling space
-OPS1="$OPS1 "
-# Re-add trainling \$
-for ((i=0; i<$SHLVL; i++)); do OPS1="$OPS1\\$"; done
-
-PS1="$OPS1 "
-
-
 if test -n "$BASH_VERSION"; then
    [ "`type -t ls`" = alias ] && unalias ls
    [ "`type -t ll`" = alias ] && unalias ll
@@ -160,6 +152,11 @@ if test -n "$BASH_VERSION"; then
    fi
    complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser
 
+   if [ "`type -t short_curdir`" != function -a \
+         -r "$HOME"/admin/prog/short_curdir ]; then
+      . "$HOME"/admin/prog/short_curdir
+   fi
+
    #if type -p pip >/dev/null 2>&1; then
    #   eval "`pip completion --bash`"
    #   rm -rf /tmp/pip_build_"$USER"
@@ -344,7 +341,11 @@ include() {
 mc() {
    if test -n "$BASH_VERSION"; then
       MC_SAVE_OPS1="$OPS1"
-      OPS1="\u@\h "
+      if [ "`type -t short_curdir`" = function ]; then
+         OPS1="\u@\h \`short_curdir\` \\$"
+      else
+         OPS1="\u@\h \W \\$"
+      fi
    fi
 
    if [ -n "$SLOWTERM" ]; then