Move to Chezmoi
This commit is contained in:
parent
f216c4ff2c
commit
e3498e73b5
59 changed files with 499 additions and 2240 deletions
chezmoi/dot_zshrc.d
37
chezmoi/dot_zshrc.d/executable_fup.sh
Normal file
37
chezmoi/dot_zshrc.d/executable_fup.sh
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
# fup uploads a given file to file.io
|
||||
fup() {
|
||||
local -r FILE_PATH="${1}"
|
||||
local -r EXPIRATION="${2}"
|
||||
if ! [ -f "${FILE_PATH}" ]; then
|
||||
echo 'provide a valid file path'
|
||||
return 1
|
||||
fi
|
||||
|
||||
local URL='https://file.io/'
|
||||
|
||||
if [ -n "${EXPIRATION}" ]; then
|
||||
URL="${URL}?expires=${EXPIRATION}"
|
||||
fi
|
||||
|
||||
local JSON_RETURN
|
||||
if ! JSON_RETURN="$(curl -SsfLF "file=@${FILE_PATH}" "${URL}")"; then
|
||||
echo 'Curl failed'
|
||||
return 1
|
||||
fi
|
||||
|
||||
if echo "${JSON_RETURN}" | grep -q '"success":false'; then
|
||||
echo "${JSON_RETURN}"
|
||||
return 2
|
||||
fi
|
||||
|
||||
echo "https://file.io/$(echo "${JSON_RETURN}" | sed 's/.*key":"//' | sed 's/".*//')"
|
||||
|
||||
if echo "${JSON_RETURN}" | grep -q '"expiry":'; then
|
||||
echo "Expires in $(echo "${JSON_RETURN}" | sed 's/.*expiry":"//' | sed 's/".*//')"
|
||||
else
|
||||
echo 'Expires in 14 days'
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue