I'm trying to have a shortcut for going back a few dirs. Something like "cd ...." == "cd <number of dots - 1> * '../'"
- I tried doing alias '...'='../..' && cd ... but got "No such file or directoy"
- I then tried doing alias '...'='../..' but got "invalid alias name"
- I guess I can create a function:
function bla { for i in $(seq $(($1 - 1))); do cd ../; done; }; bla 3
but that seems less elegant (and also I cd ../ one in a time which is bad (cd -
won't have the desired effect for example) but I can concat the strings and only cd at the end)
My questions are: How to solve (1) & (2) and is there a neater way for this?
I'd recommend
With that, you can simply type
...
and go up two directories (even easier thancd ...
!)You can even make a whole set of them:
...and so on
Alternately, if you want to skip all that typing, this will create all the aliases up to 100 directories:
Use a function like this:
So you pass the argument of how many dirs you want to go back. Example: