From 21caf6ea770ac8bd497102439262681e34a25c07 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Tue, 29 Nov 2011 11:10:56 -0500 Subject: [PATCH] Truly make python an optional dependency of the sprunge plugin --- plugins/sprunge/sprunge.plugin.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/sprunge/sprunge.plugin.zsh b/plugins/sprunge/sprunge.plugin.zsh index aa854ede2..fed20d16f 100644 --- a/plugins/sprunge/sprunge.plugin.zsh +++ b/plugins/sprunge/sprunge.plugin.zsh @@ -48,15 +48,19 @@ FILENAMES HERE } -sprunge_syntax() { - echo "try: +if (( $+commands[python] )); then + sprunge_syntax() { + echo "try: from pygments.lexers import get_lexer_for_filename print(get_lexer_for_filename('$1').aliases[0]) except: print('text')" | python -} + } +else + sprunge_syntax() { echo 'text' } +fi -sprunge () { +sprunge() { local urls url file syntax urls=()