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
1.5k
0
Share
git-jumpを解放する / loosen editor dependency of git-jump
社内Lightning Talkの資料です
Yoichi NAKAYAMA
February 13, 2023
More Decks by Yoichi NAKAYAMA
See All by Yoichi NAKAYAMA
小さなOSS貢献の実践例 / A practical example of a small contribution to OSS
yoichi
0
180
ターミナル出力の色付け / Terminal output coloring
yoichi
0
220
パイプの話 / on pipe
yoichi
0
580
バイナリリーディング / Binary Reading
yoichi
0
440
OSS開発を楽しく続けてきた話
yoichi
0
920
Other Decks in Programming
See All in Programming
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.4k
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
120
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
220
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
330
今さら聞けないCancellationToken
htkym
0
210
AIエージェントの隔離技術の徹底比較
kawayu
0
450
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
11k
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
290
新規プロダクトを高速で生み出すハーネスエンジニアリング
seanchas116
19
7.7k
次世代リンターで探る、tsgo 時代における型認識カスタムルールの現実解
ytakahashii
3
1.4k
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
410
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.2k
Featured
See All Featured
Music & Morning Musume
bryan
47
7.2k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
Making Projects Easy
brettharned
120
6.7k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Design in an AI World
tapps
1
220
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
310
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を任意 のプログラムに渡せるように