Ag Fasd Fzf终端模糊搜索神器 Li.009

ag比grep快速的速度, 同时打印出搜索词的行数. Fasd 时空机, 瞬间跳到去过的目录, 或定位打开过的文件. Fzf 模糊搜索工具. 1. 安装ag fasd fzf 1.1 Mac安装ag fasd fzf. brew install the_silver_searcher fzf fasd # 以下内容添加到~/.zshrc或~/.bashrc中 eval "$(fasd --init auto)" # 重新生效 source ~/.zshrc 或 source ~/.bashrc 1.2 Linux安装ag fasd fzf. yum install the_silver_searcher fasd git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/install 2. 别名 alias jan='fasd -a' # any alias js='fasd -si' # show / search / select alias jd='fasd -d' # directory alias jf='fasd -f' # file alias jsd='fasd -sid' # interactive directory selection alias jsf='fasd -sif' # interactive file selection alias j='fasd_cd -d' # cd, same functionality as j in autojump alias jz='fasd_cd -d -i' # cd with interactive selection alias jdd='fasd -D' # 删除一个路径 alias v='jf -e vim' alias nv='jf -e nvim' alias catf='jf -e cat' alias py3f="jf -e python3" alias lsf="jd -e ls" alias shf='jf -e sh' alias commandf='jf -e command' # preview file alias ffp='fzf --preview '"'"'[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (rougify {} || highlight -O ansi -l {} || coderay {} || cat {}) 2> /dev/null | head -500'"'" # 跳到最近匹配的目录中 jj() { [ $# -gt 0 ] && fasd_cd -d "$*" && return local dir dir="$(fasd -Rdl "$1" | fzf -1 -0 --no-sort +m)" && cd "${dir}" || return 1 } jje() { [ $# -gt 0 ] && fasd_cd -d "$*" && return local dir dir="$(fasd -Rdl "$1" | fzf -e -1 -0 --no-sort +m)" && cd "${dir}" || return 1 } # 从当前路径搜索并跳转 jcd() { local dir dir=$(find ${1:-....

July 20, 2021 · 2 分钟 · Lizicai