qu "去"
hui "回"
anders@~#qu .tencent/
/home/anders /home/anders/.tencent/
anders@~/.tencent#qu qq
/home/anders /home/anders/.tencent/ /home/anders/.tencent/qq
anders@~/.tencent/qq#hui
anders@~/.tencent#hui
anders@~#
--------.bashrc-------
# anders bash exercise
declare -a FOLDER_ARRAY
export FOLDER_ARRAY
FOLDER_ARRAY[0]=$(pwd)
qu ()
{
dirname=$1
if [ $# -eq 0 ] || [ ! -d $1 ]; then
echo "usage:qu
return
else
if [ ${dirname:0:1} != "/" ]; then
dirname=$(pwd)/$dirname
fi
FOLDER_ARRAY[${#FOLDER_ARRAY[@]}]=$dirname
cd $dirname
echo ${FOLDER_ARRAY[@]}
fi
}
hui ()
{
if [ ${#FOLDER_ARRAY[@]} -le 1 ]; then
echo "no back way"
return
else
unset FOLDER_ARRAY[$((${#FOLDER_ARRAY[@]}-1))]
cd ${FOLDER_ARRAY[$((${#FOLDER_ARRAY[@]}-1))]}
fi
}
没有评论:
发表评论