# HG changeset patch # User Jeff Hammel # Date 1372017251 25200 # Node ID 71345f4de3ce1c82751574108bd3d85bc4c47b86 # Parent 481b55fc4b96ddc6f1bdaae521853197ae7835b6 programs to list make targets diff -r 481b55fc4b96 -r 71345f4de3ce bin/make-targets.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/make-targets.sh Sun Jun 23 12:54:11 2013 -0700 @@ -0,0 +1,3 @@ +#!/bin/bash +# list makefile targets +make -pn | grep '^ *[^#].*:.*' | sed 's/\([^:]+\):.*/\1/' | sort | uniq \ No newline at end of file diff -r 481b55fc4b96 -r 71345f4de3ce bin/swapscreens.sh --- a/bin/swapscreens.sh Sat Jun 22 15:58:21 2013 -0700 +++ b/bin/swapscreens.sh Sun Jun 23 12:54:11 2013 -0700 @@ -1,6 +1,13 @@ #!/bin/bash # swap screens between internal laptop monitor and external monitor +# XXX sensitive to the individual laptop :( + +# See also `unxrandr`: +# unxrandr - inverse tool of xrandr +# unxrandr is a tool that queries the XRandR state using ARandR's +# libraries and outputs an xrandr command line that reproduces the state + INTERNAL="LVDS1" EXTERNAL="VGA1" diff -r 481b55fc4b96 -r 71345f4de3ce python/make-targets.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/make-targets.py Sun Jun 23 12:54:11 2013 -0700 @@ -0,0 +1,63 @@ +#!/usr/bin/python + +""" +list the targets for a makefile +""" + +import argparse +import subprocess +import sys + +call = subprocess.check_output + +def main(args=sys.argv[1:]): + + ignore = ['%', '.', '(', '/'] + + parser = argparse.ArgumentParser() + parser.add_argument("-a", "--all", action="store_true", + help="show all matches") + parser.add_argument("--origin", action="store_true", + help="show original line") + args = parser.parse_args(args) + + if args.all: + ignore = [] + + line_dict = {} + names = [] + output = call(["make", "-pn"]).strip() + for index, line in enumerate(output.splitlines()): + _orig = line + line = line.strip() + if not line: + continue + if line.startswith('#'): + continue + if ':' not in line: + continue + name, rhs = line.split(':', 1) + if rhs and rhs[0] == '=': + continue + name = name.strip() + if '=' in name or not name: + continue + + # ignore thingies + if name.startswith(tuple(ignore)): + continue + + names.append(name) + line_dict.setdefault(name, (index, _orig)) + + names = list(set(names)) + names.sort() + if args.origin: + for name in names: + index, line = line_dict[name] + print '%s: `%s`:%d' % (name, line, index+1) + return + print '\n'.join(names) + +if __name__ == '__main__': + main()