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
dirscommand to print the directory stack π¨οΈ - the
cdhcommand 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