mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +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() {
|
sprunge() {
|
||||||
if [ -t 0 ]; then
|
if [ -t 0 ]; then
|
||||||
echo Running interactively, checking for arguments... >&2
|
|
||||||
if [ "$*" ]; then
|
if [ "$*" ]; then
|
||||||
echo Arguments present... >&2
|
|
||||||
if [ -f "$*" ]; then
|
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 "$*"
|
cat "$*"
|
||||||
else
|
else
|
||||||
echo Uploading the text: \""$*"\"... >&2
|
|
||||||
echo "$*"
|
echo "$*"
|
||||||
fi | curl -F 'sprunge=<-' http://sprunge.us
|
fi | curl -F 'sprunge=<-' http://sprunge.us
|
||||||
else
|
else
|
||||||
echo No arguments found, printing USAGE and exiting. >&2
|
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo Using input from a pipe or STDIN redirection... >&2
|
|
||||||
while read -r line ; do
|
while read -r line ; do
|
||||||
echo $line
|
echo $line
|
||||||
done | curl -F 'sprunge=<-' http://sprunge.us
|
done | curl -F 'sprunge=<-' http://sprunge.us
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue