summaryrefslogtreecommitdiffstats
path: root/fb
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2009-10-03 21:38:55 +0200
committerFlorian Pritz <bluewind@xssn.at>2009-10-03 21:38:55 +0200
commit578af9df6bf801d42a5b8cd1604550b8cfa342bb (patch)
tree6932508664a55701075f8c2fb96eb4960af32c21 /fb
parentb6310b067ed26ab874ed38c880ac2647a96aa7a3 (diff)
downloadbin-578af9df6bf801d42a5b8cd1604550b8cfa342bb.tar.gz
bin-578af9df6bf801d42a5b8cd1604550b8cfa342bb.tar.xz
fb: add support for -e extension (stdin only)
use this if you pipe code or diff and want the highlighting to work Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'fb')
-rwxr-xr-xfb13
1 files changed, 7 insertions, 6 deletions
diff --git a/fb b/fb
index de8fdea..d4f1b24 100755
--- a/fb
+++ b/fb
@@ -8,7 +8,7 @@
#----------------------------------------------------
'''[cat |] %prog [file1 file2 ...]'''
-__version__ = '0.4.0'
+__version__ = '0.4.1'
__desc__ = '''
Upload file to paste.xinu.at and copy URL to clipboard
or nopaste stdin
@@ -62,7 +62,7 @@ def merge(seq):
merged.append(x)
return merged
-def read_stdin():
+def read_stdin(tmpfile):
if os.isatty(sys.stdin.fileno()):
print '^C to exit, ^D to send'
try:
@@ -71,7 +71,6 @@ def read_stdin():
sys.exit()
if not content:
sys.exit()
- tmpfile = Popen('mktemp', stdout=PIPE).communicate()[0]
tmpfile = tmpfile.replace('\n', '')
f = open(tmpfile, 'w')
f.write(content)
@@ -84,9 +83,13 @@ def main():
description=__desc__+password.__doc__)
p.add_option('-d', '--delete', action='store_true', dest='delete',
help='delete IDs', default=False)
+ p.add_option('-e', '--extension', action='store', dest='extension',
+ help='extension for tempfiles when pipeing (e.g. "diff")', default='')
options, args = p.parse_args()
tmpfiles = []
+ tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0]
+ tmpdir = tmpdir.replace('\n', '')
if args:
for arg in args:
if options.delete:
@@ -94,8 +97,6 @@ def main():
continue
if arg.find('http://') != -1:
- tmpdir = Popen(['mktemp', '-d'], stdout=PIPE).communicate()[0]
- tmpdir = tmpdir.replace('\n', '')
os.chdir(tmpdir)
tmpfiles.append(tmpdir)
Popen(['wget', '-q', arg]).communicate()[0]
@@ -104,7 +105,7 @@ def main():
else:
do_upload(arg)
else:
- tmpfile = read_stdin()
+ tmpfile = read_stdin(tmpdir+"/stdin."+options.extension)
tmpfiles.append(tmpfile)
do_upload(tmpfile)