加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

快速跳转工具--FASD 简单介绍

发布时间:2020-12-15 16:16:25 所属栏目:安全 来源:网络整理
导读:前言 fasd是一个命令行加速工具。它提供了对文件和文件夹的快速访问。它和autojmp,z,v都很相近。它会记录你访问过的文件夹和文件, 然后你就可以通过简短的名字来直接访问它们。 fasd会对访问过的文件和文件夹按照使用频率排序,然后按照频率列出所有文件和

前言

fasd是一个命令行加速工具。它提供了对文件和文件夹的快速访问。它和autojmp,z,v都很相近。它会记录你访问过的文件夹和文件, 然后你就可以通过简短的名字来直接访问它们。
fasd会对访问过的文件和文件夹按照使用频率排序,然后按照频率列出所有文件和文件夹

命令

fasd [options] [query ...]
[f|a|s|d|z] [opions] [query ...]
  options:
    -s        list paths with scores
    -l        list paths without scores
    -i        interactive mode
    -e <cmd>  set command to execute on the result file
    -b <name>  only use <name> backend
    -B <name>  add additional backend <name>
    -a        match files and directories
    -d        match directories only
    -f        match files only
    -r        match by rank only
    -t        match by recent access only
    -R        reverse listing order
    -h        show a brief help message
    -[0-9]    select the nth entry

fasd [-A|-D] [paths ...]
    -A    add paths
    -D    delete paths

比如输入fasd -R的返回结果是

$ fasd -R
75.3984    /home/harriszh/dw/dev/dw_fp_mult/src
63.423    /home/harriszh/dw/work_version/sim_ver.2015
44.8636    /home/harriszh/avip/axi3_master_tlm_slave_tlm
43.8288    /home/harriszh/.fzf
37.4402    /home/harriszh/.zshrc
35.572    /home/harriszh/dw/dev/dw_fp_mult
26.0366    /home/harriszh/.fzf/shell
25.6842    /home/harriszh/.vim/bundle
...

配置

ZSH:

# fasd
fasd_cache="$HOME/.fasd-init-zsh"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
  fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache

BASH:

fasd_cache="$HOME/.fasd-init-bash"
if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
  fasd --init posix-alias bash-hook bash-ccomp bash-ccomp-install >| "$fasd_cache"
fi
source "$fasd_cache"
unset fasd_cache

aliases

带自以下aliases

alias a='fasd -a' # any
alias s='fasd -si' # show / search / select
alias d='fasd -d' # directory
alias f='fasd -f' # file
alias sd='fasd -sid' # interactive directory selection
alias sf='fasd -sif' # interactive file selection
alias z='fasd_cd -d' # cd,same functionality as j in autojump
alias zz='fasd_cd -d -i' # cd with interactive selection
建议把z和zz注释掉, 因为后面会用fzf+fasd来实现

使用

使用如下:

# list frecent files matching foo
f foo
# list frecent files and directories matching foo and bar             
a foo bar  
# list frecent files that ends in js    
f js$ 
# run vim on the most frecent file matching foo              
f -e vim foo  
# run mplayer on the most frecent file matching bar     
mplayer `f bar`
# cd into the most frecent directory matching foo    
z foo
# interact               
open `sf pdf`

问题

在zsh里配合fzf使用时经常会出现这个错误

fasd_cd:1: maximum nested function level reached

这时应该检查一下fasd有没有被其它脚本alias

后言

fasd单独使用也非常强大,但配合fzf会再强大,所以fasd只是三剑客之一,另外两剑客是ag和fzf.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读