mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Sprunge plugin detects the syntax
This commit is contained in:
parent
8224455bd9
commit
3f3da1eb47
1 changed files with 16 additions and 16 deletions
|
|
@ -41,22 +41,22 @@ exit
|
|||
|
||||
sprunge() {
|
||||
if [ -t 0 ]; then
|
||||
echo Running interactively, checking for arguments... >&2
|
||||
if [ "$*" ]; then
|
||||
echo Arguments present... >&2
|
||||
if [ -f "$*" ]; then
|
||||
echo Uploading the contents of "$*"... >&2
|
||||
# Use python to attempt to detect the syntax
|
||||
syntax=$(echo "try:
|
||||
from pygments.lexers import get_lexer_for_filename
|
||||
print(get_lexer_for_filename('$*').aliases[0])
|
||||
except:
|
||||
print('text')" | python)
|
||||
cat "$*"
|
||||
else
|
||||
echo Uploading the text: \""$*"\"... >&2
|
||||
echo "$*"
|
||||
fi | curl -F 'sprunge=<-' http://sprunge.us
|
||||
else
|
||||
echo No arguments found, printing USAGE and exiting. >&2
|
||||
usage
|
||||
fi
|
||||
else
|
||||
echo Using input from a pipe or STDIN redirection... >&2
|
||||
while read -r line ; do
|
||||
echo $line
|
||||
done | curl -F 'sprunge=<-' http://sprunge.us
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue