#!/bin/sh
# JUMP version 1.0 (C)  by   Weijin Mai   Jan-11-93
# 
# this script and two C/C++ routines let you jump to any directory in your
# system there is also a MS_DOS version, email me if you are want a copy .
# 
# I would appreciate if you make any improvement to this utility and send me
# a copy of you modified source code.
#          cl820@cleveland.freenet.edu (preferred)
#          or wjmcc@cunyvm.cuny.edu



 dir_data_file=$HOME/.dirdata.cpy
 dir_data_tmp_file=$HOME/.dirdata.tmp

DirNotFount()
{
   #echo "! Directory" $1 "  no found !"
  
   UpdateDir 
   jumpdir $1 && alias go='cd `grep / $HOME/.jumppath.tmp`' || echo "You are hopless, do you make a typo?"
         
   return 0
}


UpdateDir()
{
   echo "updating directory...Please wait..."
   echo "Press Control-C to stop scanning"
   
   du / 2> $HOME/.du.err | awk '{print $2 }' > $dir_data_tmp_file
   parsedir $dir_data_tmp_file | sort > $dir_data_file
   rm -f $dir_data_tmp_file
   mv $dir_data_file $HOME/.dirdata.jmp

   echo "Now you have an updated directory data file" 
   rm -f $HOME/.du.err
   return 0  
}


if [ -z $1 ]
then
   echo "Usage   : . j [dir_name  OR  partial_dir_name+]  OR  -update]"
   echo  "Example : . j bin    OR   . j de]  show all dir_name start with de"
       
elif [ $1 = "-update" ]
then 
   UpdateDir
else
   
   jumpdir $1 && alias go='cd `grep / $HOME/.jumppath.tmp`' || DirNotFount $1

fi

if [ -f $HOME/.jumppath.tmp ]
then 
  go
  rm  -f $HOME/.jumppath.tmp
  alias go=''
  
fi




























