mirror of
https://github.com/skywind3000/z.lua
synced 2026-03-17 05:09:49 +00:00
update doc
This commit is contained in:
@@ -20,7 +20,8 @@ z.lua 是一个快速路径切换工具,它会跟踪你在 shell 下访问过
|
||||
- 新增:环境变量 "$_ZL_ADD_ONCE" 设成 1 的话性仅当前路径改变时才更新数据库。
|
||||
- 新增:增强匹配模式,将环境变量 "$_ZL_MATCH_MODE" 设置成 1 可以启用。
|
||||
- 新增:交互选择模式,如果有多个匹配结果的话,跳转前允许你进行选择。
|
||||
- 新增:支持 fzf 来进行多结果筛选,见后面文档。
|
||||
- 新增:支持 fzf 来进行多结果筛选,见后面文档。
|
||||
- 新增:快速跳转到父目录,代替反复 “cd ../../.." 。
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
71
README.md
71
README.md
@@ -26,7 +26,8 @@ For example, `z foo bar` would match `/foo/bar` but not `/bar/foo`.
|
||||
- New "$_ZL_ADD_ONCE" to allow updating database only if `$PWD` changed.
|
||||
- Enhanced matching mode with "$_ZL_MATCH_MODE" set to 1.
|
||||
- Interactive selection enables you to choose where to go before cd.
|
||||
- Support fzf for selecting from multiple results.
|
||||
- Support fzf for selecting from multiple results (optional).
|
||||
- Quickly go back to a parent directory instead of typing "cd ../../..".
|
||||
|
||||
|
||||
## Examples
|
||||
@@ -249,6 +250,64 @@ Usually, `z -I` can be aliased to `zf` (z + fuzzy finder) for convenience. If th
|
||||
|
||||
NOTE: For fish shell, this feature requires fish 2.7.0 or above. You can specify fzf executable in `$_ZL_FZF` environment variable, `"fzf"` will be called by default.
|
||||
|
||||
## Jump Backwards
|
||||
|
||||
New option `"-b"` to quickly go back to a specific parent directory in bash instead of typing "cd ../../.." redundantly.
|
||||
|
||||
- **(No argument)** `cd` into the project root:
|
||||
|
||||
Use `z -b` with no argument, it will look for the project (checkout) directory (the one with `.git`/`.hg`/`.svn` in it) and then `cd` into it.
|
||||
|
||||
- **(One argument)** `cd` into the closest parent having its name begin with whatever the value you passed in:
|
||||
|
||||
If you are in this path `/home/user/project/src/org/main/site/utils/file/reader/whatever` and you want to go to `site` directory quickly,
|
||||
|
||||
then just type: `z -b site`
|
||||
|
||||
In fact, You can simply type `z -b <starting few letters>` like `z -b s` or `z -b si`.
|
||||
If there are more than one directories with same name up in the hierarchy, `z -b` will take you to the closest.
|
||||
|
||||
- **(Two arguments)** replace the first value with the second one (in the current path).
|
||||
|
||||
Let's start by alising `z -b` to `zb`:
|
||||
|
||||
```bash
|
||||
# go all the way up to the project root (in this case, the one that has .git in it)
|
||||
~/github/lorem/src/public$ zb
|
||||
=> cd ~/github/lorem
|
||||
|
||||
# cd into to the first parent directory named g*
|
||||
~/github/vimium/src/public$ zb g
|
||||
=> cd ~/github
|
||||
|
||||
# substitute jekyll with ghost
|
||||
~/github/jekyll/test$ zb jekyll ghost
|
||||
=> cd ~/github/ghost/test
|
||||
```
|
||||
|
||||
## Echo target result
|
||||
|
||||
Backward jumping can also be used with `$_ZL_ECHO` option (echo $pwd), which makes it possible to combine them with other tools (without actually changing the working directory):
|
||||
|
||||
```bash
|
||||
# Assuming we are in ~/github/vim/src/libvterm
|
||||
# Enable $_ZL_ECHO to emit a pwd command after cd
|
||||
$ _ZL_ECHO=1
|
||||
|
||||
# see what's in my project root
|
||||
$ ls -l `zb`
|
||||
=> ls -l ~/github/vim
|
||||
|
||||
# check log in "<project root>/logs"
|
||||
$ tail -f `zb`/logs/error.log
|
||||
=> tail -f ~/github/vim/logs/error.log
|
||||
|
||||
# list some parent directory
|
||||
$ ls -l `zb git`
|
||||
=> ls -l ~/github
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
@@ -258,6 +317,7 @@ Recommended aliases you may find useful:
|
||||
alias zc='z -c' # restrict matches to subdirs of $PWD
|
||||
alias zz='z -i' # cd with interactive selection
|
||||
alias zf='z -I' # use fzf to select in multiple matches
|
||||
alias zb='z -b' # cd backwards to parent directory
|
||||
```
|
||||
|
||||
|
||||
@@ -319,12 +379,13 @@ awk -F '\t' '{print $2 "|" $1 "|" 0}' $FN >> ~/.zlua
|
||||
- 0.1.0 (2018-04-30): supports windows cmd, cmder and conemu.
|
||||
- 0.0.0 (2018-03-21): initial commit, compatible with original z.sh.
|
||||
|
||||
## Credit
|
||||
## Thanks
|
||||
|
||||
Releated projects:
|
||||
Thanks to @rupa for inspiring me to start this project.
|
||||
Thanks to @vigneshwaranr and @shyiko for inspiring me the backward jumping.
|
||||
Thanks to @TeddyDD for fish shell porting.
|
||||
|
||||
- [rupa/z](https://github.com/rupa/z): origin z.sh implementation
|
||||
- [JannesMeyer/z.ps](https://github.com/JannesMeyer/z.ps): z for powershell
|
||||
And many others.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Reference in New Issue
Block a user