Skip to content

Instantly share code, notes, and snippets.

@argiopetech
Last active March 14, 2023 15:06
Show Gist options
  • Save argiopetech/7881413 to your computer and use it in GitHub Desktop.
Save argiopetech/7881413 to your computer and use it in GitHub Desktop.
Snippet to implement the ZSH autopushd functionality in BASH. `dc` (the inverse of `cd`) and `flip` utilities are included. `cd` is silent and behaves as the builtin with no argument. `dc` and `flip` list directory stack.
# Credit to http://unix.stackexchange.com/a/4291 for the cd() implementation.
alias dc='popd'
alias flip='pushd'
function cd()
{
if [ $# -eq 0 ]; then
DIR="${HOME}"
else
DIR="$1"
fi
builtin pushd "${DIR}" > /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment