aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.bash_utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-04-26 15:52:55 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-04-26 15:52:55 +0200
commita36d29ac755e76d91bbb1236e9bbef2bdfaadcb1 (patch)
tree265b11faf79e48b067be6db9203edb62e502b580 /%HOME%/.bash_utils
parentssh: update my hosts (diff)
downloadlinux-home-a36d29ac755e76d91bbb1236e9bbef2bdfaadcb1.tar.gz
linux-home-a36d29ac755e76d91bbb1236e9bbef2bdfaadcb1.zip
file.sh: add pastebin function
Diffstat (limited to '%HOME%/.bash_utils')
-rw-r--r--%HOME%/.bash_utils/file.sh16
1 files changed, 16 insertions, 0 deletions
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/
+)