2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nyagosでghqとgh-openをpecoってつかいたかった

Last updated at Posted at 2015-04-14

pecoには、表示結果をCtrl+Spaceで複数選択できるという機能があります。
複数のリポジトリを一気にブラウザで参照したい時に不便だったので例によってnyagosのaliasでつくりました。

alias {
  phq = function (arg)
    local arg = string.format("%s", arg[1])
    local str = nyagos.eval("ghq list -p | peco")
    if (str ~= nil ) then
      if arg == "open" then
        for line in string.gmatch(str, '[%a|%p]+[\n]*') do
          nyagos.exec("gh-open "..'"'..chomp(line)..'"')
        end
      else
        nyagos.exec("cd ".. '"' ..chomp(str).. '"')
      end
    end
  end
}

function chomp(src)
    return string.gsub(src, "[\r\n]+$", "")
end

使い方

nyagos.dにphq.luaを放り込むか、.nyagosに記述します。

C:>phq

ghq getしてきたローカルリポジトリの一覧を表示します。

C:>phq open

gh-openを繰り返し行うので、ctrl+spaceで複数行を渡しても開いてくれます。

#謝辞
nyagos
ghq
gh-open
peco

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?