惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
小众软件
小众软件
爱范儿
爱范儿
Y
Y Combinator Blog
博客园 - Franky
美团技术团队
博客园 - 【当耐特】
The Cloudflare Blog
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
IT之家
IT之家
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
WordPress大学
WordPress大学
V
Visual Studio Blog
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
有赞技术团队
有赞技术团队

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Faster Directory Navigation with z.lua
2019-02-14 · via jdhao's digital space

If you work with terminals extensively, you may be tired of typing cd to go to directories, especially when directory names are very long. z.lua is such a tool to make your life easier by jumping to the desired directory smartly.

Install#

Linux (bash)#

If you are using bash shell, you need to download the plugin manually. Down and z.lua file and add the following setting to your .bashrc.

# change /path/to/z.lua to the actual path of z.lua file
eval "$(lua /path/to/z.lua --init bash enhanced once)"

Linux (zsh)#

If you are using zsh, you can install this plugin with antigen:

antigen bundle skywind3000/z.lua

Windows (Cmder)#

z.lua requires that the lua binary is in your PATH. The easiest way to install lua binary is to install LuaDist. Just extract it to somewhere on your system and add the path the lua.exe to your system PATH.

Then, copy file z.lua and z.cmd to $CMDERROOT/vendor folder and add $CMDERROOT/vendor to your system PATH.

Make sure to reboot your computer after you have updated the system PATH to make the change take effect.

How to use#

First, you need to cd to a few directories after installing z.lua to build the cd history. After that, to go a directory containing keyword foo, use the following command:

Command completion#

z.lua supports command completion. To start completion, press <Tab> after the keyword, for example,

Interactive selection#

Sometimes, several directories may contain the same keywords. You can use z with -i option to start interactive path selection:

All directories containing foo will be listed with its index, you can then type a index to go to a specific directory.

Jump backward to parent folder#

To jump backward to parent directories, use z -b command. Suppose that you are in directory ~/github/foo/bar/util, to go to foo directory, simply use the following command:

other settings#

Other useful settings are:

export _ZL_MATCH_MODE=1  # enhanced matching mode
export _ZL_ECHO=1  # display the path after cd
export _ZL_ADD_ONCE=1  # only add path if the $PWD is changed

We can also create alias for commonly-used command:

# alias for z.lua
alias zi="z -i"  # interactive selection
alias zb="z -b"  # jump backward

References#