nがひとつ多い。

えぬなおの技術的なことを書いていくとこ。

OSXでfzf(peco) + ghq + Intellijでコマンドラインからintellij IDEAを呼ぶ

TL;DR

peco + ghq + VS Codeとかでやってるのと変わらんけど。

VS Codeでもghq - Qiita

ghq, peco, hubで快適Gitライフを手に入れよう! - Qiita

ghqでインストール済みのレポジトリをIntellij IDEAで開く

gi() {
  local REPO=$(ghq root)/$(ghq list | fzf)
  if [ ! "${REPO}" = "$(ghq root)/" ]; then
    /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea ${REPO}
  fi
}

ghqで未インストールのレポジトリをIntellij IDEAで開く

ggi() {
  if [ -z ${1} ]; then
    echo "Usage: ${0} <github repo URL>"
    return 1
  fi
  local RESULT=""
  ghq get ${1}
  if echo ${1} | grep 'https://' >/dev/null 2>&1 ; then
    RESULT=$(echo ${1} | cut -c 9-)
  elif echo ${1} | grep 'git@' >/dev/null 2>&1 ; then
    RESULT=$(echo ${1} | sed  "s&git@github.com:&github.com/&") 
  fi

  if echo ${RESULT} | grep '.git' >/dev/null 2>&1 ; then
    RESULT=$(echo ${RESULT} | rev | cut -c 5- | rev)
  fi

  /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea $(ghq root)/${RESULT}
}