2013-07-09 8 views

答えて

2

使用しているオペレーティングシステムについては言及していませんが、Linuxの場合は「ラッパー」スクリプトを作成できます。 git-grep1のような名前のシェルスクリプトを作成し、$ PATHにあるディレクトリに入れてください。そうすれば、gitはそれを見つけることができます。次に、あなたのスクリプトが組み込みのgitコマンドであるかのようにgit grep1 param1 param2...と入力することができます。

は、ここであなたが始めるために簡単な例です:

# Example use: find C source files that contain "pattern" or "pat*rn" 
# $ git grep1 '*.c' pattern 'pat*rn' 

# Ensure we have at least 2 params: a file name and a pattern. 
[ -n "$2" ] || { echo "usage: $0 FILE_SPEC PATTERN..." >&2; exit 1; } 

file_spec="$1" # First argument is the file spec. 
shift 
pattern="-e $1" # Next argument is the first pattern. 
shift 

# Append all remaining patterns, separating them with '--and'. 
while [ -n "$1" ]; do 
    pattern="$pattern --and -e $1" 
    shift 
done 

# Find the patterns in the files. 
git grep -i "$pattern" -- "$file_spec" 

あなたは、たとえば、おそらくによって拡大を防ぐために、単一引用符で$file_specと各パターンを囲むことで、これを試して、おそらく必要がありますシェル。

0

あなたは、文字列の相対的な順序を知っているのならば、たぶんのTextExpanderを使う

git grep str1.*str2.*str3 -- *strings*txt 
関連する問題