[Linux-Biella] cd [ e cd ] come back e next

Paolo Ciarrocchi paolo.ciarrocchi a gmail.com
Mer 24 Maggio 2006 22:48:36 CEST


Ciao a tutti,
grazie a Debarshi Ray <rishi a gnu.org>, aggiungendo le seguenti righe
nel file .bashrc è possibile usare i comandi
$cd [
$cd ]

come i back e next di un browser.


__COUNT=0
__BACK=0
cd ()
{
if [ "${1}" = "[" ]; then
if [ "${__BACK}" -lt "${__COUNT}" ]; then
pushd +1 > /dev/null
__BACK=$(($__BACK+1))
else
echo "can't go back any more"
fi
elif [ "${1}" = "]" ]; then
if [ "${__BACK}" != 0 ]; then
pushd -0 > /dev/null
__BACK=$(($__BACK-1))
else
echo "can't go forward any more"
fi
elif [ "${1}" = "." ]; then
builtin cd "${@}"
else
if [ "${1}" = "-" ]; then
pushd "${OLDPWD}" > /dev/null
elif [ "${#}" -eq 0 ]; then
pushd "${HOME}" > /dev/null
else
pushd "${@}" > /dev/null
fi
while [ "${__BACK}" -gt 0 ]; do
popd -0 > /dev/null
__BACK=$(($__BACK-1))
done
__COUNT=$(($__COUNT+1))
fi
}


Io lo trovo molto comodo .-)

-- 
Paolo
http://paolociarrocchi.googlepages.com


Maggiori informazioni sulla lista Linux