Zsh快速路径跳转之zoxide
在Zsh
中实现快速路径跳转,
之前已经介绍了z.lua
(Zsh配置快速路径跳转)。今天看到了另一个zsh
的插件zoxide
,
它是用rust
语言写的,所以效率上应当是更高的。至于为什么会由z.lua
切换到zoxide
,
这里我也想不出更好的理由,但是大家可以参考文章zoxide VS
z.lua和zsh-z VS
zoxide, 今天我是做为尝试而切换到zoxide
,
当然z.lua
依然优秀。
zoxide 简介
zoxide is a smarter cd command, inspired by z and autojump.
It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes.zoxide works on all major shells.
Getting started
1 | z foo # cd into highest ranked directory matching foo |
Installation
1 | sudo pacman -S zoxide |
Configure
1 | # set for zsh-z-git |
对比配置信息来看,zoxide
好像更加简洁一些,但是这不是主要的切换依据,几个工具都可以尝试。我认为z.lua
是从aur
中安装的,但是zoxide
是从Archlinux
的官方仓库中安装,使用官方的工具我认为更可靠一些。
Import your data
If you currently use any of these plugins, you may want to import your data
autojump
Run this command in your terminal:
1 | zoxide import --from=autojump "/path/to/autojump/db" |
The path usually varies according to your system:
OS | Path | Example |
---|---|---|
Linux | $XDG_DATA_HOME/autojump/autojump.txt or
$HOME/.local/share/autojump/autojump.txt |
/home/alice/.local/share/autojump/autojump.txt |
macOS | $HOME/Library/autojump/autojump.txt |
/Users/Alice/Library/autojump/autojump.txt |
Windows | %APPDATA%\autojump\autojump.txt |
C:\Users\Alice\AppData\Roaming\autojump\autojump.txt |
fasd, z, z.lua, zsh-z
Run this command in your terminal:
1 | zoxide import --from=z "path/to/z/db" |
The path usually varies according to your system:
Plugin | Path |
---|---|
fasd | $_FASD_DATA or $HOME/.fasd |
z (bash/zsh) | $_Z_DATA or $HOME/.z |
z (fish) | $Z_DATA or $XDG_DATA_HOME/z/data or
$HOME/.local/share/z/data |
z.lua (bash/zsh) | $_ZL_DATA or $HOME/.zlua |
z.lua (fish) | $XDG_DATA_HOME/zlua/zlua.txt or
$HOME/.local/share/zlua/zlua.txt or
$_ZL_DATA |
zsh-z | $ZSHZ_DATA or $_Z_DATA or
$HOME/.z |
ZLocation
Run this command in PowerShell:
1 | $db = New-TemporaryFile |