哈哈哈哈

人生天地间,忽如远行客。

0%

autojump安装及使用

新机器上暂时没安装autojump,要cd一长串路径,觉得麻烦,于是安装一下。

安装

macos,使用brew安装

1
brew install autojump

执行完之后,显示的信息:

1
2
3
4
5
6
7
8
9
10
Add the following line to your ~/.bash_profile or ~/.zshrc file:
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh

If you use the Fish shell then add the following line to your ~/.config/fish/config.fish:
[ -f /opt/homebrew/share/autojump/autojump.fish ]; and source /opt/homebrew/share/autojump/autojump.fish

Restart your terminal for the settings to take effect.

zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions

配置

1
2
#文件 ~/.zshrc 添加
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh
1
source ~/.zshrc

使用

后续再使用cd进入目录后,再次进入时,输入j 目录关键字,即可快速定位到目录。
关键字是路径的任一部分,会按权重排序跳转。

其他命令

1
j -s # 查看autojump数据库中记录的目录及其权重
1
j -a 路径 # 将指定的路径添加到autojump的数据库中
1
j --purge # 清理数据库中记录的不存在的路径
1
2
j -i 10 /dir # 将目录 /dir 的权重加10
j -d 10 /dir # 将目录 /dir 的权重减10