Open terminal ubuntu keyboard shortcut8/28/2023 ![]() ![]() # go to /etc, then /, then /usr/local and then back to the default anchor: Here's an excerpt from the README.md: # make the current directory the default anchor: ![]() In addition, this question contains some tips that you might find useful when working on the command-line:Īnc was designed exactly for that use case. It becomes particularly useful when you have particularly deep directories and can use it to set up the directory stack to quickly move between them. Then with your last popd you will return to ~. In general the beauty of this is that you can set up the directory stack and the order of items within it with pushd and then, say you have three files to edit in each of those directories, you can return instantly to each one with popd while removing them from the directory stack. ~/Downloads/folder/interest ~/Music/artist/album ~Īnd the prompt reads ~/Downloads/folder/interest$ Once you have the directory stack arranged in the order you want, you can use popd to quickly cycle through the directories and then return to the home folder for example, from Pictures we can return to Downloads: popd You can keep on doing this without removing them from the stack, although any folders you cd to, other than those added to the directory stack with pushd, will alter your directory stack. ~/Pictures/Canon/2012_07_01 ~/Downloads/folder/interest ~/Music/artist/album ~ If you have exactly the stack arrangement as the above dirs listing shows, pushd +3 switches you to the specific Pictures folder and places that on top of the stack (it is +3 and not +4 as you do not count your ~ in the directory stack): pushd +3 For more on that useful stack rotation see the Bash manpage. You actually don't need to use popd straightaway as that removes directories from the stack the best thing to do is to use pushd to rotate the stack, so that you can keep switching between the directories and order them as you want. ~/Downloads/folder/interest ~/Music/artist/album ~ ~/Pictures/Canon/2012_07_01 In a sense you bookmark the location where you want to return by entering pushd /home/mike/Pictures/Canon/2012_07_01Īnd then you can add more directories to the stack, so you get a dirs listing as below, which includes 3 designated folders and your ~ home folder: dirs The clearest explanation is in this very useful article and is exactly the way I use pushd and popd:įirstly, use dirs or dirs -l to list directories on the stack and dirs -c to clear the stack. There are no separate manpages for the commands, as they are included in the Bash manpage, but for quick reference you can view the GNU Bash page. It takes a bit of getting used to, but there are plenty of useful tutorials out there at this blog and this this site for example. The dirs builtin displays the contents of the directory stack. The pushd builtin adds directories to the stack as it changes the current directory, and the popd builtin removes specified directories from the stack and changes the current directory to the directory removed. In contrast to the autojump bookmarks mentioned by burger.ga, the directory stack created by using pushd is only temporary.Īs the GNU manual notes, pushd and popd are Bash builtins used to construct a temporary directory stack that is a ![]() ![]() More information here: (also instruction on how to install this from src which gets you the most recent version)Įven though there are some good answers already, I thought I'd mention for completeness the old pushd and popd Bash builtins with allow you to move very quickly between directories in deep paths in your filesystem. To install you can just use sudo apt-get install autojump and then you need to add source /usr/share/autojump/autojump.bash Stuff_1_/home/user/this/long/and/annoyingly/deep/directory/workstuffĪnd then you can just press the number of the directory you want! However it gets better! If you also have the directory /home/user/stuffĪnd then Tab Tab Tab you get (in the order of most visited) $ j stuff_ If more than one directory matches you jump to the one that is most visited, if this is not the one you wanted, then repeat the command to go to the second. Then if you have visited it once you can jump to it by j workstuffīecause it also works with partial matches. So for instance you have /home/user/this/long/and/annoyingly/deep/directory/workstuff Also have a look at autojump, it builds a database with previously visited directories and then you can jump to it. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |