LoginSignup
0
0

More than 3 years have passed since last update.

fish + peco の関数サンプル

Last updated at Posted at 2021-02-12

履歴検索

# History search by peco
function peco_history
  history | peco --prompt="HISTORY>" | read select_hist
  commandline $select_hist
end

GHQによるディレクトリ移動

# Change directory by peco + ghq
function peco_ghq
  ghq list | peco --prompt="GHQ>" | read select_dir
  if [ $select_dir ]
    cd (ghq root)/$select_dir
  end
end

下層のファイル探索

# Find by peco + (git ls-files or find)
function peco_find
  function source_files
    if git rev-parse 2> /dev/null
      git ls-files
    else
      find . -type f
    end
  end
  source_files | peco --prompt "FIND>" | read select_file
  commandline $select_file
end

ショートカット登録

function fish_user_key_bindings
  bind \cr peco_history # ctrl + r
  bind \cg peco_ghq     # ctrl + g
  bind \cf peco_find    # ctrl + f
end
0
0
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
0