Skip to content

Commit

Permalink
Format identation and shell check
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuscomh committed Sep 16, 2023
1 parent 7a1ba47 commit 217b012
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions yourl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,33 @@ op_short='short link '
op_upload='file sent'

case "$1" in
'' | -h | --help) echo "$usage"; exit;;
-v | --version) echo "$version"; exit;;
'' | -h | --help)
echo "$usage"
exit
;;
-v | --version)
echo "$version"
exit
;;
esac

if [[ -f "$1" ]]; then
# If $1 is file
read <<< $(curl -sF "file=@$1" https://0x0.st | sed -e "s/<.*//")
op="$op_upload"
read -r <<<"$(curl -sF "file=@$1" https://0x0.st | sed -e "s/<.*//")"
op="$op_upload"
else
# If $1 is a url
read <<< $(curl -s http://tinyurl.com/api-create.php?url="$1")
op="$op_short"
read -r <<<"$(curl -s http://tinyurl.com/api-create.php?url="$1")"
op="$op_short"
fi

# Validate read input and exit if error
[[ -z "$REPLY" || "$REPLY" = 'Error' ]] && exit 1

# Print url shorted on bash
#echo "$REPLY"
command -v qrencode &> /dev/null && qrencode -m 2 -t ANSIUTF8 "$REPLY"
echo $REPLY
command -v qrencode &>/dev/null && qrencode -m 2 -t ANSIUTF8 "$REPLY"
echo "$REPLY"

# Send a shorted url to clippboard Linux/MacOS
command -v xclip &> /dev/null && echo -n "$REPLY" | xclip -sel copy || echo -n "$REPLY" | pbcopy 2> /dev/null
command -v xclip &>/dev/null && echo -n "$REPLY" | xclip -sel copy || echo -n "$REPLY" | pbcopy 2>/dev/null

0 comments on commit 217b012

Please sign in to comment.