Bash tip of the day: ff

25 March 2011   2 comments   Linux

Mind That Age!

This blog post is 7 years old! Most likely, its content is outdated. Especially if it's technical.

Powered by Fusion×

This is helping me sooo much that it would a crime not to share it. It's actually nothing fancy, just a very convenient thing that I've learned to get used to. ff is an executable script I use to find files in a git repository. Goes like this:

$ ff list
$ ff venue

It makes it easy to super quickly search for added files without having to use the slow find command which would also otherwise find backup files and other junk that isn't checked in.

To install it, create a file called ~/bin/ff and make it executable:

$ chmod +x ~/bin/ff

Then type this code in:

import sys, os
args = sys.argv[1:]
i = False
if '-i' in args:
   i = True
pattern = args[-1]
extra_args = ''
if len(args) > 1:
   extra_args = ' '.join(args[:-1])
param = i and "-i" or ""
cmd = "git ls-files | grep %s %s '%s'" % (param, extra_args, pattern)


Why not just add to your .bashrc:

alias ff="git ls-files | grep"
fyi your postings keep appearing double (with a significant delay) in my google reader.
Thank you for posting a comment

Your email will never ever be published

Related posts

My AWS CloudFront bill 23 March 2011
Google's new Page Speed Online hard to beat 04 April 2011
Related by Keyword:
A neat trick to zip a git repo with a version number 01 September 2017
gg - A prototype to rule Git, GitHub and Bugzilla 06 May 2016
.git/info/exclude, .gitignore and ~/.gitignore_global 20 April 2016
And bash basics 16 October 2015
How I git 18 June 2015
Related by Text:
gg - wrapping git-grep 11 August 2009
Git + Twitter = Friedcode 22 April 2009
Ctags in Atom on OSX 26 February 2016
Really simple Django view function timer decorator 08 December 2017
jsonpprint - a Python script to format JSON data nicely 21 November 2010