#!/usr/bin/env python import os import sys import urllib import urllib2 URL = 'http://dumpz.org/add/' if len(sys.argv) < 2: sys.exit("Not enough parameters.") elif len(sys.argv) > 2: sys.exit("Too many parameters.") fname = sys.argv[-1] if os.path.exists(fname): fcont = open(fname,'r').read() ext = fname.split('/')[-1].split('.')[-1] highlighting = 'text' if ext == 'sh': highlighting = 'bash' elif ext in ['c', 'h']: highlighting = 'c' elif ext in ['cpp', 'hpp']: highlighting = 'cpp' elif ext in ['html','htm']: highlighting = 'html' elif ext == 'php': highlighting = 'php' elif ext == 'py': highlighting = 'python' elif ext == 'css': highlighting = 'css' elif ext == 'sql': highlighting = 'sql' values = { 'lexer': highlighting, 'code': fcont, } data = urllib.urlencode(values) req = urllib2.Request(URL ,data, {'Content-type':'application/x-www-form-urlencoded'}) res = urllib2.urlopen(req) url = res.url print "Pasted at %s" % url print "Trying to add to clipboard using xclip.." os.system('echo -n "%s" | xclip' % url) else: sys.exit("File not found: %s" % fname)