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
2024年のWebフロントエンドのふりかえりと2025年
sakito
1
230
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
640
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
CI改善もDatadogとともに
taumu
0
110
CNCF Project の作者が考えている OSS の運営
utam0k
5
690
Pulsar2 を雰囲気で使ってみよう
anoken
0
230
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
11
1.8k
Amazon Q Developer Proで効率化するAPI開発入門
seike460
PRO
0
110
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
730
Ruby on cygwin 2025-02
fd0
0
140
『品質』という言葉が嫌いな理由
korimu
0
160
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
41
15k
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
Visualization
eitanlees
146
15k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
The Invisible Side of Design
smashingmag
299
50k
Optimizing for Happiness
mojombo
376
70k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
400
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
950
Product Roadmaps are Hard
iamctodd
PRO
50
11k
A Tale of Four Properties
chriscoyier
158
23k
Six Lessons from altMBA
skipperchong
27
3.6k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
240
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を任意 のプログラムに渡せるように