Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Linux/Unix Efficiency Tool: Quick path switch z command


May 31, 2021 Article blog


Table of contents


The article was reproduced from the public number: Talk about software testing

Brief introduction

z is an open source Linux fast path switching tool (similar tools include z.lua autojump fasd Frecent Frecent of paths accessed on a daily basis through the Frecency mechanism z you switch to the path with the highest weight value in all paths that match regular keywords.

Frecency was developed by Mozilla to combine the frequency and newness of access (the time difference between the last visit and the present) into a measured heuristic.

See for details: github.com/rupa/z

Installation

# /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

use

Tip: z command can be patched with tab to improve switching efficiency.

# 查看帮助
$ 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 .

Here's what W3Cschool编程狮 has to say about Linux/Unix Efficiency Tools: Quick Path Switch z commands.