Skip to content

Instantly share code, notes, and snippets.

@peebeebee
Created June 26, 2015 09:00
Show Gist options
  • Select an option

  • Save peebeebee/a27468df8aaca92fefc3 to your computer and use it in GitHub Desktop.

Select an option

Save peebeebee/a27468df8aaca92fefc3 to your computer and use it in GitHub Desktop.
Handy Shell Functions
# .bash_profile
# Type `up 7` to do cd ../../../../../../..
function up() {
i=$1
while [ $i -gt 0 ]
do
cd ..
i=$(($i - 1))
done
}
> up 7
# Instead of counting folders it can be done by typing a few characters of the name of the parent folder you want to go.
function up {
cd `expr "$PWD" : "^\(.*$1[^/]*\)"`
}
> up han
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment