PUSHD(1)

πŸ’… pushd β€” push directory to directory stack

okay so bestie, this one is a fish-shell function (yep, we're in fish-shell land, not bash πŸ‘€) and it's about to become your new fave thing. It's the little directory-stack bestie that lets you hop around folders and then rewind like nothing happened. πŸŽ€


✨ SYNOPSIS ✨

pushd DIRECTORY

πŸ¦‹ DESCRIPTION πŸ¦‹

The pushd function adds DIRECTORY to the top of the directory stack and makes it the current working directory. That's it, that's the whole vibe. πŸ’–

Then when you're done, popd will pop it off and return you to the original directory. It's giving "teleport there, teleport back" energy and honestly? Iconic. ✨

Without arguments, it exchanges the top two directories in the stack. Lowkey a little shuffle, no cap. πŸ”„

  • pushd +NUMBER β€” rotates the stack counter-clockwise, i.e. from bottom to top πŸ’«
  • pushd -NUMBER β€” rotates clockwise, i.e. top to bottom πŸ”ƒ

Also, the -h or --help option displays help about using this command. Because even main characters need a little help sometimes 🫢


🌸 EXAMPLE 🌸

cd ~/dir1
pushd ~/dir2
pushd ~/dir3
# Working directory is now ~/dir3
# Directory stack contains ~/dir2 ~/dir1

pushd /tmp
# Working directory is now /tmp
# Directory stack contains ~/dir3 ~/dir2 ~/dir1

pushd +1
# Working directory is now ~/dir3
# Directory stack contains ~/dir2 ~/dir1 /tmp

popd
# Working directory is now ~/dir2
# Directory stack contains ~/dir1 /tmp

see how it just stacks up your whole life and then unwinds it?? literally the most satisfying thing ever 😭πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

  • the dirs command to print the directory stack πŸ–¨οΈ
  • the cdh command which provides a more intuitive way to navigate to recently visited directories 🌈

✨ ngl bestie, if you're forever lost in your own filesystem, cdh might be your actual soulmate. iykyk πŸ’…

Copyright β€” fish-shell developers 🧚

sending you off with love from version 4.9, dated Sep 08, 2026 β€” stay stacked, stay slaying πŸ’œπŸšβœ¨

πŸ“¦ where this page comes from
  • arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms