diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-04-26 15:52:55 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-04-26 15:52:55 +0200 |
commit | a36d29ac755e76d91bbb1236e9bbef2bdfaadcb1 (patch) | |
tree | 265b11faf79e48b067be6db9203edb62e502b580 /%HOME%/.bash_utils | |
parent | ssh: update my hosts (diff) | |
download | linux-home-a36d29ac755e76d91bbb1236e9bbef2bdfaadcb1.tar.gz linux-home-a36d29ac755e76d91bbb1236e9bbef2bdfaadcb1.zip |
file.sh: add pastebin function
Diffstat (limited to '')
-rw-r--r-- | %HOME%/.bash_utils/file.sh | 16 |
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/ +) |