Saturday, June 25, 2016

fasd, .bashrc に alias を設定

fasd, .bashrc に alias を設定。

################################################
# fasd
################################################

eval "$(fasd --init auto)"

alias fa='fasd -a' # any
alias fs='fasd -si' # show / search / select
alias fd='fasd -d' # directory
alias ff='fasd -f' # file
alias fsd='fasd -sid' # interactive directory selection
alias fsf='fasd -sif' # interactive file selection

# cd, same functionality as j in autojump
alias fcd='fasd_cd -d'
#alias fcd_no_cl='fasd_cd -d'
#alias fcd="fcd_no_cl;clear;pwd;ls -lGh"

# cd with interactive selection
#alias scd="'fasd_cd -d -i;clear';pwd;ls -lGh" # cd with interactive selection
alias scd_no_cl='fasd_cd -d -i' # cd with interactive selection
alias scd="scd_no_cl;clear;pwd;ls -lGh"

# open with interactive selection
function fscd_open() {
    open "$(fasd -sif)"
}
alias sop='fscd_open'


alias fvi='ff -e /opt/local/bin/vim' # quick opening files with vim
alias fmp='ff -e mplayer' # quick opening files with mplayer
#alias o='a -e xdg-open' # quick opening files with xdg-open

 

そうすると、scd という自分の設定したコマンドを叩くと、「過去、自分が入ったディレクトリの一覧」から、「今、自分の行きたいディレクトリ」を対話的に選んだうえで、そこに直接、行くことができる。また、コマンド終了後、clear;pwd;ls -Gh が終わっている。


確かに、便利だ。

ただし、気になる。fasd に慣れすぎると、各ファイルやディレクトリの位置を自分があまり意識しないようになるのかな? しかし、それは怖いような気もするが・・・。

 

<参考にしたページ>
fasdチュートリアル(メモ)

peco と fasd で快適なターミナル生活(Mac へのインストール) 

clvv/fasd 

Fasd - Quickly Jump to Recent Files and Folders - Linux CLI 

No comments:

Post a Comment