Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
git-jumpを解放する / loosen editor dependency of git...
Search
Yoichi NAKAYAMA
February 13, 2023
Programming
0
1.3k
git-jumpを解放する / loosen editor dependency of git-jump
社内Lightning Talkの資料です
Yoichi NAKAYAMA
February 13, 2023
Tweet
Share
More Decks by Yoichi NAKAYAMA
See All by Yoichi NAKAYAMA
小さなOSS貢献の実践例 / A practical example of a small contribution to OSS
yoichi
0
120
ターミナル出力の色付け / Terminal output coloring
yoichi
0
140
パイプの話 / on pipe
yoichi
0
470
バイナリリーディング / Binary Reading
yoichi
0
350
OSS開発を楽しく続けてきた話
yoichi
0
800
Other Decks in Programming
See All in Programming
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
270
Honoとフロントエンドの 型安全性について
yodaka
4
250
Open source software: how to live long and go far
gaelvaroquaux
0
620
DROBEの生成AI活用事例 with AWS
ippey
0
130
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
4
370
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
2,500万ユーザーを支えるSREチームの6年間のスクラムのカイゼン
honmarkhunt
6
5.1k
Rails アプリ地図考 Flush Cut
makicamel
1
110
Java Webフレームワークの現状 / java web framework at burikaigi
kishida
9
2.2k
Grafana Cloudとソラカメ
devoc
0
140
Unity Android XR入門
sakutama_11
0
140
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
300
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
90
5.8k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Optimizing for Happiness
mojombo
376
70k
Speed Design
sergeychernyshev
25
780
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
630
Faster Mobile Websites
deanohume
306
31k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Pragmatic Product Professional
lauravandoore
32
6.4k
BBQ
matthewcrist
86
9.5k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Transcript
git-jumpを解放する Yoichi Nakayama
gitのサブコマンド “git ほにゃらら [args…]” の「ほにゃらら」 どんなサブコマンドを知ってますか?
gitのサブコマンドいろいろ git のサブコマンドを作ったことがありますか? • git clone • git checkout •
git add • git commit • git branch • git tag • git log • git blame • git merge • git reset • git rebase • git status • git push • git fetch • git pull • …
gitのサブコマンドの作り方 git-foo という実行可能ファイルをPATHに配置 →サブコマンド git foo を定義できる 例: % echo
'echo "hello world"' > ~/bin/git-hello % chmod +x ~/bin/git-hello % git hello hello world
サブコマンドの例: git-set-file-times (rsyncに付属) ワーキングツリーのファイルのタイムスタンプをコミット時刻に合わせる https://github.com/WayneD/rsync/blob/master/support/git-set-file-times https://speakerdeck.com/yoichi/a-practical-example-of-a-small-contribution-to-oss
サブコマンドの例: git-restore-branch (自作) 削除したローカルブランチをリストアップ、復元する https://github.com/yoichi/git-restore-branch/blob/main/git-restore-branch https://zenn.dev/yoichi/articles/git-restore-branch
今日の題材: git-jump (git に付属) 興味のある要素にエディタでジャンプする • diff: diff hunks •
merge: merge conflicts • grep: grep hits • ws: whitespace errors https://github.com/git/git/blob/master/contrib/git-jump/git-jump
git-jumpの利用シーン • git grep キーワードにマッチした行を表示 • 周りの行を見たいなー → git grep
-C で前後の行も合わせて表示 • エディタで見れたらいいのになー → git jump grep
git-jumpの実装(シェルスクリプト) • 興味のある要素を「ファイル名:行番号:コンテンツ」の形式でファイル出力 • vim -q で開く https://vim-jp.org/vimdoc-ja/quickfix.html
「ファイル名:行番号:コンテンツ」の形式 git-jumpに限らず、 あちこちで見かける: • コンパイラのエラー出力 • 静的解析ツールの出力 • grep -n
の出力 これを入力として受け取れる プログラムはVim以外もある →Vim縛りを外すには?
「ファイル名:行番号:コンテンツ」の形式 git-jumpに限らず、 あちこちで見かける: • コンパイラのエラー出力 • 静的解析ツールの出力 • grep -n
の出力 これを入力として受け取れる プログラムはVim以外もある →Vim縛りを外すには? https://speakerdeck.com/yoichi/on-pipe
やったこと:git jumpで標準出力に出すオプションを追加 →quickfix list を任意のプログラム(例えば、Emacs の M-x grep)で使える
git-jumpの出力をEmacsで扱える ≠ git-jumpのEmacs対応 git jump –stdout で任意のプログラム(e.g. M-x grep)に出力を渡せるようになった •
diff: diff hunks • merge: merge conflicts • grep: grep hits • ws: whitespace errors git-jumpの機能: • 興味のある要素にエディタでジャンプする • =ターミナルでコマンドを打つと、素早くエディタが立ち上がる → Vimだけでなく、Emacsも制御できるようにしたい
やったこと:git jumpでEmacsを制御できるように EDITOR環境変数の複数のパターンに対応 • emacs 新しいEmacsプロセスを起動(同期) • emacsclient 既存のEmacsフレームを使う(非同期) •
emacsclient -c 新しいEmacsフレームを作る(同期) • emacsclient -t 現在のターミナルに新しいEmacsフレームを作る(同期) 工夫と手抜き • emacsとemacsclientで共通の –eval オプションを使う • 非同期の場合に一時ファイル削除の競合条件が発生しないよう待ち合わせ • 一時ファイルパス中の特殊文字への対応は従来のVim向けと同程度まで
デモ: git-jump with EDITOR=”emacsclient -t”
https://github.com/git/git/blob/master/Documentation/RelNotes/2.40.0.txt (次の版) "git jump" (in contrib/) learned to present the
"quickfix list" to its standard output, and learned to also drive emacs/emacsclient. まとめ:git-jumpを特定エディタへの依存から解放した git-jump –stdout 任意のプ ログラム git-jump git-jump Vimだけでなく、Emacsも制御できるように 標準出力を経由して、 git由来のquickfix listを任意 のプログラムに渡せるように