url="$(pbpaste)" file="$(basename $url)" ext="${file##*.}" tmpfile=$(mktemp -t image) tmpfile_ext="${tmpfile}.${ext}" mv "$tmpfile" "$tmpfile_ext" wget -O "$tmpfile_ext" "$url" echo -n "$tmpfile_ext" | pbcopy