LoginSignup
0
1

More than 5 years have passed since last update.

最近 vim で編集したファイルを、peco で選択して開く

Last updated at Posted at 2018-03-06

vim で最近開いたファイルの一覧は ~/.viminfo に入っているので、これを活用する。

下記のコマンドで、掲題のことが実行できる。

vim $(egrep '^>' ~/.viminfo | cut -c3- | perl -E 'say for map { chomp; $_ =~ s/^~/$ENV{HOME}/e; -f $_ ? $_ : () } <STDIN>' | peco)

for fish users

自分は fish ユーザーで、 Ctrl + v で上記のコマンドを実行したかったので、下記のようにした。

まず関数の定義を作る

~/.config/fish/functions/peco_open_recent_file.fish
function peco_open_recent_file
    vim (egrep '^>' ~/.viminfo | cut -c3- | perl -E 'say for map { chomp; $_ =~ s/^~/$ENV{HOME}/e; -f $_ ? $_ : () } <STDIN>' | peco)
end

config.fish に以下の記述を追加すれば OK 。

~/.config/fish/confog.fish
function fish_user_key_bindings
    bind \cv peco_open_recent_file
end
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