If your directory level is very deep, this shell will be very convenient to switch directly to the destination directory, such as
Current directory/usr/home, and directory Desdir in/usr/home/app/local/opp/william/desdir
Direct penetration
$ CD Desdir, you can switch directly from the current directory/use/home to/usr/home/app/local/opp/william/desdir
Configure. Profile, add two lines
. ./bin/chdir
Alias cd= ' ChDir '
File:chdir
# Auto Find your directory
# Writer:william 2006 Beijing
# Add the following two line in $HOME/.profile
# . ./bin/chdir
# alias cd= ' ChDir '
ChDir ()
{
If [-Z "$"]; Then
Cd
Ps1= "[$PWD]"
Export PS1;
Return
elif ["$" =-]; Then
CD-
Ps1= "[$PWD]"
Export PS1;
Return
Else
If [-D "./$1"]; Then
CD./$1
Ps1= "[$PWD]"
Export PS1;
Return
Fi
Fi$HOME-type D-print | Grep-c \/$1$ '
Todo
If [$LINE-eq 0]; Then
echo "Your directory is not exsit ($LINE)!"
Return
Fi
Done
For Dir in ' Find $HOME-type d-print | grep \/$1$ '
Todo
If [$LINE-gt 1]; Then
if [!-D "$Dir"]; Then
echo "$Dir is not a directory"
Return
Fi
printf "$Dir \t\t...do you want to go? Default (Y)
Read Yesno
# echo "(y/n) =" $YESNO
If [-Z "$YESNO"]; Then
Yesno=y
Fi
Case "$YESNO" in
[yy]| [YY] [EE] [SS])
Yesno=y;;
[nn]| [NN] [OO])
Yesno=n;;
*)
Yesno= "";;
Esac
If ["$YESNO" = y]; Then
CD $Dir
Ps1= "[$PWD]"
Export PS1;
Return
Else
Continue
Fi
Else
CD $Dir
Ps1= "[$PWD]"
Export PS1;
Return
Fi
Done
}