LoginSignup
1
0

More than 1 year has passed since last update.

Mac + ghq + peco — GithubのURLをショートカットで開けるようにする例

Last updated at Posted at 2018-08-27

動作例

選ぶと

image.png

開く

image.png

動作環境

Mac + zsh + ghq + peco

手順

  • ghq で リモートレポジトリを管理しておく
    • こんな感じでレポジトリを ghq 管理に入れるだけ ( ghq get https://github.com/YumaInaura/zsh/)
  • peco で インクリメンタルサーチする
  • zsh の bindkey でショートカットを作る

~.zshrc に以下を追加

_ghq_open() {
  if [ ! $(which peco) ]; then echo "You need peco" && exit 1; fi

  local remote_repository_web_url=$(ghq list | sed -e 's/^/https:\/\//g' | peco --query="$BUFFER")

  if [ ! -z "$remote_repository_web_url" ]; then
    BUFFER="open $remote_repository_web_url"
    zle accept-line
  fi
}

zle -N ghq-open _ghq_open

bindkey '^G^O' ghq-open

ghq list で得られる一覧の先頭に https:// を付けているだけ

Versions

  • Mac OS High Sierra
  • zsh 5.5.1 (x86_64-apple-darwin17.5.0)
  • ghq version 0.8.0
  • peco version v0.5.3 (built with go1.10)

Links

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

1
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
1
0