Skip to content

Commit 18a2cc9

Browse files
committed
feat: add in helper function to upload to katbin
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
1 parent f28a783 commit 18a2cc9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

functions

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,19 @@ GDrive ID: \`${GDRIVE_UPLOAD_ID}\`
222222
tgm "${UPLOAD_INFO}"
223223
echo "Get the file with ${GDRIVE_UPLOAD_ID}"
224224
}
225+
226+
# Paste content to katb.in
227+
function katbin() {
228+
local content
229+
if [[ -z "$1" ]]; then
230+
if [[ -t 0 ]]; then
231+
echo "Error: No content provided. Provide as argument or pipe in."
232+
return 1
233+
else
234+
content=$(cat)
235+
fi
236+
else
237+
content="$1"
238+
fi
239+
curl -sL 'https://katb.in/api/paste' --json '{"paste":{"content":"'"$content"'"}}' | jq -r '"https://katb.in/\(.id)"'
240+
}

0 commit comments

Comments
 (0)