Skip to content

Instantly share code, notes, and snippets.

@NULLx76
Last active August 28, 2015 20:45
Show Gist options
  • Save NULLx76/6550a08c075df3027606 to your computer and use it in GitHub Desktop.
Save NULLx76/6550a08c075df3027606 to your computer and use it in GitHub Desktop.
Bash function that goes up X directories. (for in your ~/.bashrc)
up(){
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
if [ -z "$d" ]; then
d=..
fi
cd $d
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment