Last active
March 8, 2017 16:06
-
-
Save heapwolf/f4eedc8f02bb2e6a59c7 to your computer and use it in GitHub Desktop.
Download and show image in terminal (iterm2 only)
This file contains hidden or 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 | |
function print_image() { | |
printf "\033]" | |
printf "1337;File=" | |
echo -n "$1" | base64 -D | wc -c | awk '{printf "size=%d",$1}' | |
printf ";inline=1:" | |
echo -n "$1" | |
printf "\a\n" | |
} | |
re='(https?)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]\.(png|jpg|gif|jpeg)' | |
if [[ $1 =~ $re ]] | |
then | |
print_image "$(curl -vs "$1" 2>/dev/null | base64)" | |
exit 0 | |
else | |
exit 1 | |
fi |
I'm sorry, I'm trying to figure out where i'd put this and how i'd run this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
INTEGRATION
IRSSI