Skip to content

Instantly share code, notes, and snippets.

@heapwolf
Last active March 8, 2017 16:06
Show Gist options
  • Save heapwolf/f4eedc8f02bb2e6a59c7 to your computer and use it in GitHub Desktop.
Save heapwolf/f4eedc8f02bb2e6a59c7 to your computer and use it in GitHub Desktop.
Download and show image in terminal (iterm2 only)
#!/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
@dannymichel
Copy link

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