
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com
Mobile version of this page
Previous:
Public calendars on Google Calendar
Next:
Google Reverse Geocoding vs. GeoNames
Git + Twitter = Friedcode
Redirect stderr into becoming dots in Bash
Grep results expanded
Find print statements in Python code
Public calendars on Google Calendar
Next:
Google Reverse Geocoding vs. GeoNames
Related blogs
Grep in JedGit + Twitter = Friedcode
Redirect stderr into becoming dots in Bash
Grep results expanded
Find print statements in Python code
Related by category
gg - wrapping git-grep
11th of August 2009
I've grown quite addicted to this and finding that it's saving me tonnes of milliseconds every day. First of all, I've made this little script and put it in my bin directory called '~/bin/gg':
#!/usr/bin/python
import sys, os
args = sys.argv[1:]
i = False
if '-i' in args:
i = True
args.remove('-i')
pattern = args[-1]
extra_args = ''
if len(args) > 1:
extra_args = ' '.join(args[:-1])
if i:
param = "-in"
else:
param = "-n"
cmd = "git grep %s %s '%s'" % (param, extra_args, pattern)
os.system(cmd)
Basically, it's just a lazy short hand for git grep ("Look for specified patterns in the working tree files"). Now I can do this:
peterbe@trillian:~/MoneyVillage2 $ gg getDIYPackURL Homesite.py:526: def getDIYPackURL(self): zpt/homepage/index_html.zpt:78: tal:attributes="href here/getDIYPackURL">Get your free trial here</ zpt/moneyconcerns/index_html.zpt:36: tal:attributes="href here/getDIYPackURL">Get your free trial h zpt/moneyconcerns/index_html.zpt:50: <p><a tal:attributes="href here/getDIYPackURL" class="makea (END)
It's not much faster than normal grep but it automatically filters out junk. Obviously doesn't help you when searching in files you haven't added yet.


Save this page in del.icio.us