説明

nyagospecoを使ってgitコマンドの実行対象を選択できるようにします。
gitリポジトリ内で使用でき、以下のような機能があります。

  • git checkoutgit stash applyの対象をpecoで選択。
  • git branchgit loggit stash listで得たブランチ名、コミットハッシュ、スタッシュ番号を一行編集へ出力。

PPbを使わずnyagosを使うメリット

  • 窓位置・サイズ調整が容易。
  • lua scriptが使える。
    • バッチファイルのようなものですが標準入出力をスクリプト内で扱えます。

使い方

sample


checkout branch

コマンドを実行し、ブランチ名を選択して変更。

  • git_checkout.luaは引数が必須。第一引数に%0%\、第二引数に%nを指定。
  • 自前でrepoStat.jsを実行しません。
  • %si”gitBranch”にブランチ名が設定される。

stash apply

コマンドを実行し、スタッシュを選択して適用。

  • git_stash.luaは第一引数にオプションを指定できる。git_stash.lua "--index"
  • 自前でrepoStat.jsを実行しません。

insert branch name

一行編集上でコマンドを実行し、ブランチ名を選択して挿入。

  • git_string.luaは引数が必須。第一引数は%0%\、第二引数はbranch

insert commit hash

一行編集上でコマンドを実行し、コミットを選択して挿入。

  • git_string.luaは引数が必須。第一引数は%0%\、第二引数はcommit

insert stash number

一行編集上でコマンドを実行し、スタッシュを選択して挿入。

  • git_string.luaは引数が必須。第一引数は%0%\、第二引数はstash
  • nyagos、pecoはパスを通しておく必要あり。
  • コマンド内で、PPxWindowModuleを使用。
  • コマンド内で、git,sed,pecoを使用。
  • リポジトリの判別にrepoStat.jsを使用。
  • git_string.luaでは、出力を一時的に%si'git_string'に格納しています。

設定

; ユーザーコマンド
; path\to\の部分は環境に合わせて変更してください。
; posで位置を、modeでサイズを調整します。
; ※ppbw -c nyagos -c の部分はPPbのコンソールプロファイルを利用するための記述です。
;   nyagos -c でも構いません
_Command  = {
gitstring = *ifmatch 0,0%*extract(C"%%si'repoRoot'") %: *script %'scr'%\module\repoStat.js,1
            %Osq *run -noppb -d:%*extract(C"%%si'repoRoot'") -pos:%*windowrect(,l),%*windowrect(,b) ppbw.exe -bootid:n -c nyagos -c mode 75,15&lua_f "path\to\git_string.lua" "%0%\" %*arg(1)
}

; メニュー登録
checkout branch     = %Oq *run -noppb -d:%*extract(C"%%si'repoRoot'") -pos:360,200 ppbw.exe -c nyagos -c mode 60,20&lua_f "path\to\git_checkout.lua" %0%\

stash apply         = %Oq *run -noppb -d:%*extract(C"%%si'repoRoot'") -pos:360,200 ppbw -c nyagos -c mode 60,20&lua_f "path\to\git_stash.lua"
stash apply --index = %Oq *run -noppb -d:%*extract(C"%%si'repoRoot'") -pos:360,200 ppbw -c nyagos -c mode 60,20&lua_f "path\to\git_stash.lua" "--index"

insert branch name  = *gitstring branch
                      *insert %*extract(C"%%si'git_string'")
                      *execute C,*string i,git_string=
insert commit hash  = *gitstring commit
                      *insert %*extract(C"%%si'git_string'")
                      *execute C,*string i,git_string=
insert stash number = *gitstring stash
                      *insert %*extract(C"%%si'git_string'")
                      *execute C,*string i,git_string=