0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

enhancd と autojump

Posted at

cd の機能の拡張。
両方とも、大文字小文字の区別無しに、部分文字列でディレクトリ移動が可能になる。 zsh だと更に便利だけど、bash でも十分戦力に。

enhancd

enhancd

別コマンドではなく cd の拡張って事で、意識せずに普段使いが出来そう。

install

$ cd ${HOME}/cmd/share
$ git clone http://github.com/b4b4r07/enhancd.git
$ cd enhancd
$ PREFIX=${HOME}/cmd make

以下を *ashrc

.bashrc
source ${HOME}/cmd/share/enhancd/enhancd.sh

使い方。

まずは普通に、cd して履歴にある程度残す。

これはコマンド履歴
$ fc -l -5
   21  cd
   22  cd Desktop
   23  cd ~/Downloads/
   24  cd ~/Documents/
   25  cd ~/Public/

で、どこにいようと、移動したい場所のユニーク文字列(大文字小文字区別無し)を cd の引数に与えれば、 cd 出来る様になる。

$ cd dow
  • 上の例だと wnl だと駄目(autojump では出来る @mac
  • cd - 0
    は当環境では効かない。web の説明文では 0 の存在が無い様に書かれてるけど、man では 0 を含めた説明文。ページの gif でも cd - 0 してる。
  • jo に該当するものがあれば、移行できるのに。

autojump

mac では brew でも配布

install

$ git clone git://github.com/joelthelion/autojump.git
$ cd autojump/                          
$ python install.py --prefix=${HOME}/cmd

以下を *ashrc へ。

.bashrc
# export FPATH=${HOME}/.autojump/functions:$FPATH # <= .zshrc はこの行も
source ${HOME}/.autojump/etc/profile.d/autojump.sh

mac からサーバ上の joxdg-open させると、何故だか firefox の方に飛ばされてパスツリーを表示してしまうので、 gnome-open を叩く様に変更。単独で xdg-open すると普通にファイラー開くのに、何故だろう?

$ pwd
${HOME}/cmd/share/autojump
$ diff autojump.bash  autojump.bash.bak
97,98c97
<                 #xdg-open "${output}"
<                 gnome-open "${output}"
---
>                 xdg-open "${output}"

# 必要なら、 autojump.zsh も同様に編集

使い方。

上の enhancd の例の様に使うには、

$ j dow

他には、 jo dow でファイラー(ファインダ)を開くとか。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?