When I want to go one directory up I use
cd ..
But when I want to go 7 directories up is there any way to do this other than just typing seven (7) times cd .. ?
Join Stack Overflow to learn, share knowledge, and build your career.
Also another useful navigation tip is if for example lets say you keep switching from a directory (call it A) to another (call it B) that's 7 directories up, in your case. So if you're in directory A:
That will move right back to directory A. |
|||||||||
|
|
Make alias (in you ~/.bashrc)
and use:
UPD: Or make more powerfull variant, cd to dir name in current path:
use:
|
||||
|
|
|
you can use |
|||
|
|
|
Here is a slight improvement I have found: Usually, when you go back one directory with cd .., you end up going forward one directory after. To make this work, you have to use functions rather than aliases, so instead of:
you can use:
However, after using this, it quickly becomes apparent that you are missing command completion for this function, making it far less useful than it could be. Thus, I went back and added my own bash completion functions for this function, which can be pasted into your ~/.bashrc or any file (e.g. ~/.bash_completion) that is called from your ~/.bashrc if you wish to avoid clutter. Here is the completion code:
|
|||
|
|
|
If there is a command I use a lot I will just make an alias. You could type
Then you can just use |
||||
|
|
|
You can do it like this There is a cool article about some hacks you can apply to improve you navigation. |
|||
|
|
|
Do not remember from where I copied this function, but it works great for me (you can put in
e.g. to go 7 directories up it is necessary to type |
|||
|
|
|
|||
|
|
|
You could add the following function to your
So the usage would simply be:
|
|||||||||
|
|
Hm, I don't think so. But you can write |
|||
|
|
|
You may try this solution. It is work fine for me:
I have made alias in ~/.barsh file. And this work fine for me. |
|||
|
|
|
This nifty function supports going up in both directions. If you are in /a/b/c/d then 'up 1' will take you to /a/b/c, and so on. Thats pretty standard and covered in most of the other answers. Now, for the special part; using negative numbers takes you up from the other direction. So, if you are in /a/b/c/d, 'up -1' will take you to /a, and so on.
Available for download/install on github. |
||||
|
|
|
for fish users,
and save it to your: ~/.config/fish/functions/cdd.fish and just |
|||
|
|
cd..andcd ..are equivalent in windows but linux is too strict and rejectscd..command as invalid command just because of missing space. – RBT Feb 28 '17 at 2:10