Enhancd带有交互式过滤器的下一代 cd 命令

联合创作 · 2023-09-30 11:43

cd 命令是经常使用的命令之一。作为cd命令参数给出的目录路径必须是存在且能够解析的有效路径。换句话说,你不能将诸如“dir”(你在/home/lisa, dir 是/home/lisa/work/dir)之类的部分路径传递给cd命令。

名为 enhancd 的新 cd 命令增强了用户的灵活性和可用性。enhancd 将记住用户访问的所有目录并将其用于路径名解析。如果 enhancd 的日志有多个同名的目录路径,enhancd 会将候选目录列表传递给 ENHANCD_FILTER 环境变量中的过滤器,以便将其缩小到一个目录。

由于这种机制,用户可以直观、轻松地更改您想要访问的目录。

特征

  • 过去访问过的目录
  • 易于过滤
  • 支持 Bash、Zsh 和 fish
  • 回到特定的父目录
  • 在 git repo 中,第一个列表元素是 git 根目录
  • 相似名称目录中的模糊搜索
  • 支持标准输入
  • 自定义选项

安装

Bash

# add the fzy brew tap to homebrew
$ brew tap jhawthorn/fzy

# install fzy and ccat with homebrew
$ brew install fzy ccat

# alt: brew install fzy ccat percol peco fzf
#  depending on which interactive filter you want to use

# install enhancd into your home directory (or a preferred directory)
$ cd ~
$ git clone https://github.com/b4b4r07/enhancd

# if you want to hide the directory in the finder (gui)
$ chflags hidden enhancd

# add enhancd to your bash profile (or sourced file of choice)
$ echo "source ~/enhancd/init.sh"  >> ~/.bash_profile

# reload your bash profile
$ source ~/.bash_profile

ZSH

另外,如果你使用 zsh 作为你的 shell,你可以通过 zplug 安装它,zplug 是 zsh 的强大插件管理器:

zplug "b4b4r07/enhancd", use:init.sh

Fish

系统要求

  • Fish ≥ 3.0

使用 Fisher 安装:

fisher install b4b4r07/enhancd
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报