#/bin/bash export fn="/tmp/history.txt" history > $fn python - "$@" << END import sys args = [] if len(sys.argv) > 1: args = sys.argv[1:] if len(args) < 1: sys.stderr.write("Usage: hh ...\n") sys.stderr.write("Translates to 'history | grep | grep | ...'\n") sys.exit(1) output = open('/tmp/history.txt').readlines() # Don't consider command which invoked this script: del output[-1] for line in output: if line == None: break line = line.rstrip('\n') # Apply filters. matches_all = True for f in args: if not f in line: matches_all = False break if matches_all: print line END