とある子育てパパの日記

とある子育てパパの日記です

ghq + peco で便利な関数(bash)

みんなのGo言語zsh向けのそれは紹介してあったけど、 普段bashを使っているので、bash向けに書いてみた。

とは言っても、ほとんどネットから拝借したものだけども。

function ghql() {
  local selected_file=$(ghq list --full-path | peco --query "$LBUFFER")
  if [ -n "$selected_file" ]; then
    if [ -t 1 ]; then
      echo ${selected_file}
      cd ${selected_file}
    fi
  fi
}
bind -x '"\C-r": ghql'