Bash

function up(){# Created at: 2012/06/19 10:37:26# Go up directory tree X number of directories# source: http://orangesplotch.com/bash-going-up/# see explanation at link above, worth!# I found this here: http://askubuntu.com/questions/110922/climb-up-the-directory-tree-faster# put this function to your ~/.bashrc# binding this function to key see below# http://stackoverflow.com/questions/4200800/in-bash-how-do-i-bind-a-function-key-to-a-commandCOUNTER="[email protected]";# default $COUNTER to 1 if it isn't already setif[[ -z $COUNTER]];thenCOUNTER=1
fi# make sure $COUNTER is a numberif[$COUNTER -eq $COUNTER 2> /dev/null ];thennwd=`pwd`# Set new working directory (nwd) to current directory# Loop $nwd up directory tree one at a timeuntil[[$COUNTER -lt 1]];donwd=`dirname $nwd`let COUNTER-=1
donecd$nwd# change directories to the new working directoryelse# print usage and return errorecho"usage: up [NUMBER]"return 1
fi}