cd -1, -2, -3 etc in Z shell
问题 How do you set up the Z shell such that typing cd - gives you a list of previously visited paths, and cd -1, -2, -3, etc. will then take you to the directories? 回答1: If you have setopt AUTO_PUSHD in your .zshrc then cd will automatically do a pushd of each directory you change to. Taking the example from ZyX: $ setopt AUTO_PUSHD $ mkdir -p 1/2/3/4 $ cd 1 $ cd 2 $ cd 3 $ cd 4 You can see a list of the directories using dirs : $ dirs -v 0 ~/1/2/3/4 1 ~/1/2/3 2 ~/1/2 3 ~/1 4 ~ To be able to tab