Cool trick to navigate directories using cd !
Everyone using Linux will like to use it to navigate easily between directories. Add the following code into .bashrc file. Now you can navigate foward and backward using cd ] and cd [ .
Cool !
__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 }
Add above code to .bashrc .
Loading...
Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru
Alexwebmaster - March 3, 2009 at 10:04 am