{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiglzilkpc3oxfbgsqq6chh3upmph3rnbqfrzmg3g4isjbjb6hseyq",
"uri": "at://did:plc:viftpmw6fjjvnv3ihxf5c5c7/app.bsky.feed.post/3mmcq7dvcahk2"
},
"description": "This entire post on Christian’s blog is an absolute goldmine! While I knew most of them, I did learn a few tricks myself! That said, here's one where I find the example a bit lacking:\n\npushd and popd: If cd - is a toggle switch, pushd is a stack. Need to juggle multiple directories? pushd /etc changes to /etc but saves your previous directory to a hidden stack. When you’re done, type popd to pop it off the stack and return exactly where you left off.\n\nThis, to me, slightly undersells the power o",
"path": "/shell-tricks-that-actually-make-life-easier-and-save-your-sanity/",
"publishedAt": "2026-05-20T20:21:25.000Z",
"site": "https://chabik.com",
"textContent": "This entire post on Christian’s blog is an absolute goldmine! While I knew most of them, I did learn a few tricks myself! That said, here's one where I find the example a bit lacking:\n\n> `pushd` and `popd`: If `cd -` is a toggle switch, `pushd` is a stack. Need to juggle multiple directories? `pushd /etc` changes to `/etc` but saves your previous directory to a hidden stack. When you’re done, type `popd` to pop it off the stack and return exactly where you left off.\n\nThis, to me, slightly undersells the power of `pushd`/`popd` combo, and also doesn't mention at all `dirs` command! From the example above it's not exactly clear how `pushd /etc` followed by `popd` is better than just `cd /etc` followed by `cd -`. The true power comes when you need to juggle more than one destination! Allow me:\n\n\n # Build the stack!\n pushd ~/Music\n pushd ~/Pictures\n pushd ~/Sync\n\n # Show the stack\n dirs\n ~/Sync ~/Pictures ~/Music\n\n # Show the stack with numbers\n dirs -v\n 0 ~/Sync\n 1 ~/Pictures\n 2 ~/Music\n\n # Switch to another directory (~/Music) in the stack\n pushd +2\n\n # Show the stack again\n dirs -v\n 0 ~/Music\n 1 ~/Sync\n 2 ~/Pictures\n\n # Remove (pop) entry (~/Sync) from the stack\n popd +1\n\nBoth `pushd` and `popd` can switch or pop in the stack using `+` or `-` (I tend to gravitate more towards plus for some reason). No arguments to `popd` goes in the order as seen via `dirs -v` until the stack is empty. Quick tip: running `pushd ~/some/location` by default switches you there immediately—it can be avoided by passing `-n` flag. You're welcome.\n\nOne more expansion:\n\n> `!!`: This expands to the entirety of your previous command. Its most famous use case is the “Permission denied” walk of shame. You confidently type `systemctl restart nginx`, hit enter, and the system laughs at your lack of privileges.\n\n`!!` is genuinely clever and I do use it occasionally, but what I use even more often is argument replacement. Like so:\n\n\n systemctl status nginx\n ^status^restart\n\nYes—exactly as you'd expect, it replaces `status` in the previous command with `restart`.\n\nOverall, what a great post, thanks for sharing, Christian! 🙌🏻",
"title": "Shell Tricks That Actually Make Life Easier (And Save Your Sanity)",
"updatedAt": "2026-05-20T20:36:37.123Z"
}