From a36d29ac755e76d91bbb1236e9bbef2bdfaadcb1 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 26 Apr 2023 15:52:55 +0200 Subject: file.sh: add pastebin function --- %HOME%/.bash_utils/file.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/%HOME%/.bash_utils/file.sh b/%HOME%/.bash_utils/file.sh index ba58031..351b962 100644 --- a/%HOME%/.bash_utils/file.sh +++ b/%HOME%/.bash_utils/file.sh @@ -37,3 +37,19 @@ swap_files() ( mv -- "$path2" "$path1" mv -- "$tmp_path" "$path2" ) + +pastebin() ( + set -o errexit -o nounset -o pipefail + shopt -s inherit_errexit + + if [ "$#" -ne 1 ]; then + echo "usage: ${FUNCNAME[0]} PATH" >&2 + return 1 + fi + + local path="$1" + + # Use the .txt file extension so that when you open a link, it displays + # the contents instead of downloading. + curl -sS --connect-timeout 5 -F "file=@$path;filename=.txt" https://x0.at/ +) -- cgit v1.2.3