Skip to content

Instantly share code, notes, and snippets.

@orgoj
Last active December 15, 2015 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orgoj/5326037 to your computer and use it in GitHub Desktop.
Save orgoj/5326037 to your computer and use it in GitHub Desktop.
download script, review, and run
#!/bin/bash
if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then
echo "USAGE: wrun [-e] URL"
echo " Download file from URL, cat it and optionaly run."
echo ""
echo " Options:"
echo " -e - run editor after download"
echo ""
echo " Configuration is readed from ~/.wrun."
echo " Configuration variables:"
echo " SHOWCMD - command to run after download file (default $PAGER, cat)"
echo " EDITCMD - command to run after download file with -e option (default $EDITOR, editor)"
exit 1
fi
SHOWCMD=$PAGER
if [ "$SHOWCMD" == "" ] ; then
SHOWCMD=cat
fi
EDITCMD=$EDITOR
if [ "$EDITCMD" == "" ] ; then
EDITCMD=editor
fi
if [ -e ~/.wrun ] ; then
. ~/.wrun
fi
if [ "$1" == "-e" ] ; then
SHOWCMD=$EDITCMD
shift
fi
TMPNAME=$(mktemp)
wget -c -O $TMPNAME "$1"
echo "----------------------------------------"
$SHOWCMD $TMPNAME
echo ""
echo "----------------------------------------"
read -p "Run? [Y/n]: "
if [ "$REPLY" == "y" ] || [ "$REPLY" == "" ] ; then
chmod +x $TMPNAME
$TMPNAME
fi
rm $TMPNAME
@orgoj
Copy link
Author

orgoj commented Apr 6, 2013

sudo wget -O /usr/local/bin/wrun 'https://gist.github.com/orgoj/5326037/raw/' && sudo chmod +x /usr/local/bin/wrun

@orgoj
Copy link
Author

orgoj commented Apr 14, 2013

um wget install bin/wrun "https://gist.github.com/orgoj/5326037/raw/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment