Skip to content

Instantly share code, notes, and snippets.

@vlasovskikh
Created June 7, 2011 21:29
Show Gist options
  • Save vlasovskikh/1013219 to your computer and use it in GitHub Desktop.
Save vlasovskikh/1013219 to your computer and use it in GitHub Desktop.
See graphical diff between your old and .pacnew configs, delete .pacnew if needed
#!/usr/bin/env python
# Author: Andrey Vlasovskikh
# License: MIT
import sys
import os
import subprocess
def main():
if len(sys.argv) != 2:
print('usage: pacnew FILE', file=sys.stderr)
sys.exit(1)
filename = sys.argv[1]
pacnew = '{}.pacnew'.format(filename)
subprocess.call(['meld', filename, pacnew])
answer = input("delete '{}' [y/N]: ".format(pacnew))
if answer == 'y':
os.remove(pacnew)
else:
raise KeyboardInterrupt
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('interrupted', file=sys.stderr)
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment