Jiang LiHeng Good is good, but better carries it.

Linux/Unix 效率工具:快速路径切换 z 命令

2020-09-06
jiangliheng
本文 760 字,阅读全文约需 3 分钟

z 是一个开源的快速路径切换工具。

简介

z 是一个开源的快速路径切换工具(类似工具还有 z.luaautojumpfasd)。通过 Frecency 机制对日常访问的路径进行 Frecent 权重计算,z 会帮你切换到所有匹配正则关键字的路径中权重值最高的那条路径。

Frecency 是由 Mozilla 开发,将访问的频率和新近度(上一次访问到现在的时间差)合并为一个度量的启发式方法。

详细内容见: https://github.com/rupa/z

安装

# /usr/local 安装
$ cd /usr/local
$ sudo git clone https://github.com/rupa/z.git
$ sudo chmod +x z.sh

# zsh 配置变量
$ echo '. /usr/local/z/z.sh' >> ~/.zshrc
$ source ~/.zshrc

# bash 配置变量
$ echo '. /usr/local/z/z.sh' >> ~/.bash_profile
$ source ~/.bash_profile

# 安装 manpage
$ cp z.1 /usr/local/share/man/man1

# 验证安装
$ z -h
$ man z

使用

技巧z 命令可以使用 tab 来进行补齐,以提高切换效率。

# 查看帮助
$ man z
或
$ tldr z

# 显示记录的路径
$ z

# 切换到一个名字带有 "foo" 的路径
$ z foo

# 切换到一个名字带有 "foo" 并且后面带有 "bar" 的路径(例:fooesbar):
$ z foo bar

# 切换到名字带有 "foo" 并且拥有最高访问次数的路径
$ z -r foo

# 切换到最近使用的名字带有 "foo" 的路径
$ z -t foo

# 列出在 z 的数据库中名字带有 "foo" 的路径
$ z -l foo

# 将当前路径从 z 的数据库中移除
$ z -x .

微信公众号:daodaotest


作者:Jiang LiHeng
原文链接:https://jiangliheng.github.io/2020/09/06/linux-z/
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。


Similar Posts

Comments