多くの素晴らしいzshトリックについて学ぶための最も簡単なアクセスのためのzshallメタマンページを参照してください。 zshcontribとzshmiscのマンページも注目に値する。
ここでは、廊下のディレクトリを覚えやすくするための抜粋です。名前のディレクトリの
REMEMBERING RECENT DIRECTORIES
The function cdr allows you to change the working directory to a previous working directory from a list maintained automatically. It is similar in concept to the directory stack controlled by the pushd, popd and dirs builtins, but is more config‐
urable, and as it stores all entries in files it is maintained across sessions and (by default) between terminal emulators in the current session. (The pushd directory stack is not actually modified or used by cdr unless you configure it to do so as
described in the configuration section below.)
Installation
The system works by means of a hook function that is called every time the directory changes. To install the system, autoload the required functions and use the add-zsh-hook function described above:
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
Now every time you change directly interactively, no matter which command you use, the directory to which you change will be remembered in most-recent-first order.
Use
All direct user interaction is via the cdr function.
The argument to cdr is a number N corresponding to the Nth most recently changed-to directory. 1 is the immediately preceding directory; the current directory is remembered but is not offered as a destination. Note that if you have multiple windows
open 1 may refer to a directory changed to in another window; you can avoid this by having per-terminal files for storing directory as described for the recent-dirs-file style below.
If you set the recent-dirs-default style described below cdr will behave the same as cd if given a non-numeric argument, or more than one argument. The recent directory list is updated just the same however you change directory.
If the argument is omitted, 1 is assumed. This is similar to pushd's behaviour of swapping the two most recent directories on the stack.
Completion for the argument to cdr is available if compinit has been run; menu selection is recommended, using:
zstyle ':completion:*:*:cdr:*:*' menu selection
to allow you to cycle through recent directories; the order is preserved, so the first choice is the most recent directory before the current one. The verbose style is also recommended to ensure the directory is shown; this style is on by default so
no action is required unless you have changed it.
、あなたはhash -d name=/path
を使用し、zshrcでそれを投げることになるでしょう。あなたはその後、これらのディレクトリにcdすることができますcd ~name
楽しみがあります。
を介して他のコマンド(MV、CPなど)からのディレクトリスタックを使用することができることに注意してください。とてもかっこいい! – jackrabbit