前言
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.
原文链接:https://www.f2er.com/bash/390455.html