git grep + pecoで選択したファイルをエディタで開く
git grep便利ですよね。
git管理下にあるファイルに絞ってgrepしてくれます。
その結果をpecoを使ってさらに絞り込んで、選択した行をエディタで開くコマンドを書いてみました。
デモ
pecoとgitがインストールされている必要があります。
$ git-grep-edit word
コード
コマンド自体は数行ですが、pecoとgitがインストールされている必要があります。
#!/bin/bash
P=$(git grep -n $1 | peco | awk -F: '{print "+"$2" "$1}')
if [ ${#P} -ne 0 ]; then
$EDITOR $P;
fi
インストール
pathが通ったところに配置すれば使えますが、npmからインストールするのが手軽です。
nodeがインストールされている必要があります。
$ npm install -g git-grep-edit
Author And Source
この問題について(git grep + pecoで選択したファイルをエディタで開く), 我々は、より多くの情報をここで見つけました https://qiita.com/akameco/items/fe801449e5cd435f6851著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .