💾 Archived View for my-adventures.at › opensource › terminal › pushpopd.gmi captured on 2024-08-31 at 11:56:03. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-07-10)
-=-=-=-=-=-=-
░░░█▄█░█░█ ░░░█░█░░█░ ░░░▀░▀░░▀░ ░█▀█░█▀▄░█░█░█▀▀░█▀█░▀█▀░█░█░█▀▄░█▀▀░█▀▀ ░█▀█░█░█░▀▄▀░█▀▀░█░█░░█░░█░█░█▀▄░█▀▀░▀▀█ ░▀░▀░▀▀░░░▀░░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀ ░░░░░░░░░░░░░░░░░░░░░█▀█░▀█▀ ░░░░░░░░░░░░░░░░░░░░░█▀█░░█░ ░░░░░░░░░░░░░░░░░░░░░▀░▀░░▀░
Have you ever navigated around your terminal and wished it would remember the path to directories you need to go back to frequently as you move around your file system?
Well pushd will be your new best friend.
You may already know the
cd -
will move you back to the directory you last came from.
pushd not only moves you back to your last location but will make a list for you so you can move between a list (stack) of directory paths.
Instead of the cd (change directory) command substitute this with pushd. The path you have navigated to will be saved to your stack. You can list your stack with the following command:
dirs -v -l
To move back to you chosen path use:
pushd +n
n is the number from your stack.
When you use popd this will remove the corresponding +n from your stack.
Your stack will be modified in line with the Last in First out principal (LiFo). So your current directory will always be on 0.
You can use your stack numbers ~n with the cd and ls command as well once you have defined your stack.
-c : Clears the directory stack
-l : Produces a listing using full pathnames
-n : No stack rotation option, add a directory to the stack without changing the current directory.
-p : Print the directory stack with one entry per line (without line numbers).
-v : Print the directory stack with one entry per line (with line numbers).