-
-
Save orgoj/5326037 to your computer and use it in GitHub Desktop.
download script, review, and run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Author
orgoj
commented
Apr 6, 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