head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2004.11.24.16.29.49; author rse; state Exp; branches; next 1.3; 1.3 date 2004.10.22.19.32.52; author rse; state Exp; branches; next 1.2; 1.2 date 2004.10.22.19.16.53; author rse; state Exp; branches; next 1.1; 1.1 date 2004.07.10.08.17.15; author rse; state Exp; branches; next ; desc @@ 1.4 log @PS1 should be not adjusted in batch-mode @ text @## ## OSSP due - Dynamic User Environment ## Copyright (c) 1994-2004 Ralf S. Engelschall ## Copyright (c) 1994-2004 The OSSP Project ## ## This file is part of OSSP due, a dynamic user environment ## which can found at http://www.ossp.org/pkg/tool/due/ ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that ## the above copyright notice and this permission notice appear in all ## copies. ## ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## ## due.cd.sh: DUE module for enhanced change directory command ## # hook into cd command to adjust environment function cd () { # change current working directory if [ ".$1" = .- ]; then # go to previous working directory on forward directory stack # and move this directory onto the reverse directory stack if [ ${#DIRSTACK[*]} -gt 1 ]; then DIRSTACKREV[${#DIRSTACKREV[*]}]="${DIRSTACK[0]}" builtin popd >/dev/null else echo "cd: no more previous working directories on forward directory stack" 1>&2 return 1 fi elif [ ".$1" = .+ ]; then # go to previous working directory on reverse directory stack # and move this directory onto the forward directory stack if [ ${#DIRSTACKREV[*]} -gt 0 ]; then local i=$((${#DIRSTACKREV[*]} - 1)) eval "builtin pushd ${DIRSTACKREV[$i]} >/dev/null" unset DIRSTACKREV[$i] else echo "cd: no more previous working directories on reverse directory stack" 1>&2 return 1 fi else # go to next working directory # and move this directory onto the forward directory stack if [ $# -eq 0 ]; then set -- $HOME fi pushd ${1+"$@@"} >/dev/null if [ "${#DIRSTACK[*]}" -ge 2 -a "${DIRSTACK[0]}" = "${DIRSTACK[1]}" ]; then builtin popd >/dev/null fi DIRSTACKREV=() fi if [ ".$BASH_INTERACTIVE" = .yes ]; then # adjust the command-line prompt with new $PWD (always) PS1="\\u@@\\h:$PWD\n\\\$ " # adjust the X11 terminal window title with new $PWD (optional) case "$TERM" in xterm | xterm-* ) echo -n $'\e]0;'"$USER@@$HOSTNAME:$PWD"$'\cg' ;; esac fi } # initially adjust the environment cd $PWD PS2="> " # provide convenience shortcuts alias -- +='cd +' alias -- -='cd -' alias -- ..='cd ..' # auto-correct small errors in given directory names shopt -s cdspell @ 1.3 log @umask and ff into a new due.fs.sh module and cleanup comments @ text @d67 3 a69 2 # adjust the command-line prompt with new $PWD (always) PS1="\\u@@\\h:$PWD\n\\\$ " d71 1 a71 2 # adjust the X11 terminal window title with new $PWD (optional) if [ ".$BASH_INTERACTIVE" = .yes ]; then @ 1.2 log @do not output escape sequences in batch mode @ text @d27 1 a27 1 ## cd: DUE module for enhanced change directory command @ 1.1 log @import the initial version of the new-born OSSP due (Dynamic User Environment @ text @d71 7 a77 5 case "$TERM" in xterm | xterm-* ) echo -n $'\e]0;'"$USER@@$HOSTNAME:$PWD"$'\cg' ;; esac @