5 ms·
Looks like the Esc-. trick works in zsh as well. I didn't know about it. Cool. Thank you. With regard to pushd and popd: these tricks work in zsh also. In addi
by gcv 18y ago
Looks like the Esc-. trick works in zsh as well. I didn't know about it. Cool. Thank you.
With regard to pushd and popd: these tricks work in zsh also. In addition, (again, zsh-specific) you can set these options:
setopt auto_pushd # automatic directory stack
setopt pushd_minus # swap +/- for pushd and popd
setopt pushd_silent # no output after pushd and popd
setopt pushd_to_home # pushd with no arguments goes to ~
setopt pushd_ignore_dups # no duplicates in directory stack
With these options set, every time you change directories using cd, the directory goes into your directory stack, basically executing an implicit pushd. Then, move around the directory structure a little, and try typing 'cd -<Tab>' (meaning type 'cd -' and press Tab for autocompletion). It'll list entries in your directory stack by number (so -1 is your previous directory, -2 is the one before, and so on). It's a handy wrapper for bare pushd/popd functionality.
Bash might offer similar functionality, but I don't know much about bash.
- likpok 18y agoI doubt it. One of the big features of zsh over bash is the tab completion is fantastic (arguments, URLS, etc). With a good .zsh and .zshrc, it is an amazing experience.
- nuclear_eclipse 18y agoMy only complaint with Zsh's tab completion, which is usually far superb compared to Bash, is that package-name completion is much slower in Zsh as compared to Bash, at least on the Debian and Ubuntu systems that I use. Typing `aptitude install build-<Tab>` in Bash almost immediately completes "build-essential", but Zsh can take anywhere from 3-15 seconds to search through the package cache before completing the same package name. Other than that, I absolutely love Zsh's completion system, and the awesome capabilities it provides, like context-sensitive Git argument completion, such as `git add <Tab>` listing only the files that are either changed since the last commit, or not yet tracked by Git. Insanely useful!
- nuclear_eclipse 18y agosetopt pushd_to_home # pushd with no arguments goes to ~ I would personally dislike that, because without that option set, calling pushd (at least in Zsh) with no argument will actually rotate the top two elements on the directory stack, which can be extremely handy for switching between two places, rather than needing to constantly call `pushd +1` or `pushd -1`. e.g.: $ pu ~ /home/user $ pu workspace/project /home/user/workspace/project /home/user $ pu /tmp/data /tmp/data /home/user/workspace/project /home/user $ pu /home/user/workspace/project /tmp/data /home/user $ po /tmp/data /home/user $ po /home/user note that I alias pu="pushd" and po="popd" for easier shell usage...