Added code to allow one to use my startup scripts by doing source
authoradefaria <adefaria@adefaria-lt.audience.local>
Thu, 2 Oct 2014 19:58:36 +0000 (12:58 -0700)
committeradefaria <adefaria@adefaria-lt.audience.local>
Thu, 2 Oct 2014 19:58:36 +0000 (12:58 -0700)
~adefaria/.rc/bash_login.
Fixed bug so that when I am root the word Wizard appears in the prompt.

rc/bash_login
rc/functions

index 79d1c60..88d27e0 100644 (file)
 # (c) Copyright 2000-2005, Andrew@DeFaria.com, all rights reserved.
 #
 ################################################################################
 # (c) Copyright 2000-2005, Andrew@DeFaria.com, all rights reserved.
 #
 ################################################################################
+# The following will set HOME, temporarily, to the directory of my $HOME so that
+# somebody other than me can envoke my startup scripts. I use this mainly for
+# when I become root with sudo -s and what a better environment that the bare
+# bones root environment gives you. Note that for us to be effective one must
+# source (or .) this file and if so the ${BASH_ARGV[0]} is the normal $0
+home=$(dirname ${BASH_ARGV[0]})
+
+# Strip off .rc
+home=${home/%\/\.rc/}
+
+# Now set $HOME if $home is different.
+saved_home=$HOME
+if [ "$HOME" != "$home" ]; then
+  HOME=$home
+fi
+
 # Set ARCHITECTURE of the machine
 KERNEL=$(uname -s)
 if [[ $KERNEL = CYGWIN* ]]; then
 # Set ARCHITECTURE of the machine
 KERNEL=$(uname -s)
 if [[ $KERNEL = CYGWIN* ]]; then
@@ -260,6 +276,9 @@ done
 # Set display to local
 export DISPLAY=${DISPLAY:-:0}
 
 # Set display to local
 export DISPLAY=${DISPLAY:-:0}
 
+# Reset home in case it changed
+HOME=$saved_home
+
 # Now go home (in case we were not autmatically cd'ed there)
 if [ $(id -u) -ne 0 ]; then
   cd
 # Now go home (in case we were not autmatically cd'ed there)
 if [ $(id -u) -ne 0 ]; then
   cd
index 69f8aa1..458a69b 100644 (file)
@@ -19,7 +19,13 @@ view_name=
 
 # Function to set the title bar. Works on the terminal emulators listed.
 function title_bar {
 
 # Function to set the title bar. Works on the terminal emulators listed.
 function title_bar {
+  if [ $# -gt 1 ]; then
+    ROOT=shift
+    ROOT="${NORMAL}\($ROOT\)"
+  fi
+
   prefix="$@"
   prefix="$@"
+
   # Change $HOME -> ~
   if [ "${PWD#$HOME*}" != "$PWD" ]; then
     current_dir="~${PWD#$HOME*}"
   # Change $HOME -> ~
   if [ "${PWD#$HOME*}" != "$PWD" ]; then
     current_dir="~${PWD#$HOME*}"
@@ -53,7 +59,7 @@ function title_bar {
     string=$(echo "${SYSNAME##*:}:$@")
     echo -n "${ESC}]2;$string\007"
   elif [ "$TERM" = "cygwin" -o "$TERM" = "vt100" -o "$TERM" = "xterm" ]; then
     string=$(echo "${SYSNAME##*:}:$@")
     echo -n "${ESC}]2;$string\007"
   elif [ "$TERM" = "cygwin" -o "$TERM" = "vt100" -o "$TERM" = "xterm" ]; then
-    PS1="\[\e]0;$prefix$current_dir\a\e[01;33m\]$SYSNAME:\[\e[0m\]"
+    PS1="\[\e]0;$prefix$current_dir\a$ROOT\e[01;33m\]$SYSNAME:\[\e[0m\]"
   fi
 } # title_bar
 
   fi
 } # title_bar
 
@@ -96,7 +102,7 @@ function set_title {
     view_name=""
     title_bar "$ROOT"
   else
     view_name=""
     title_bar "$ROOT"
   else
-    title_bar "${ROOT}View: $view_name: "
+    title_bar "$ROOT" "View: $view_name: "
   fi
 
   icon_name "${SYSNAME##*:}"
   fi
 
   icon_name "${SYSNAME##*:}"