diff options
Diffstat (limited to 'conf.d/99-pastebin.zsh')
-rw-r--r-- | conf.d/99-pastebin.zsh | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/conf.d/99-pastebin.zsh b/conf.d/99-pastebin.zsh index 3eb3f36..a10c918 100644 --- a/conf.d/99-pastebin.zsh +++ b/conf.d/99-pastebin.zsh @@ -1,24 +1,29 @@ : ${PB_INSTANCE:=ptpb.pw} : ${PB_CURL_ARGS:=""} -PASTE_LOG_FILE=$HOME/.local/zsh/ptpb.log +PASTE_LOG_DIR="$HOME/.local/pb/$PB_INSTANCE" # pb upload function pbu() { - local tmp=$(mktemp) + local res if [ "$#" -eq 0 ]; then # paste from stdin - curl $PB_CURL_ARGS -sF c=@- https://$PB_INSTANCE > $tmp + res=$(curl $PB_CURL_ARGS -sF c=@- "https://$PB_INSTANCE") else - curl $PB_CURL_ARGS -sF c=@$1 https://$PB_INSTANCE > $tmp + res=$(curl $PB_CURL_ARGS -sF "c=@$1" "https://$PB_INSTANCE") fi - mkdir -p $(dirname $PASTE_LOG_FILE) - { cat $tmp; echo; } | tee -a $PASTE_LOG_FILE - cat $tmp | awk '/url/ { print $2 }' | tr -d '\n' | xclip -i + local url=$(awk '/url/ { print $2 }' <<<"$res" | tr -d '\n') + local short=$(awk '/short/ { print $2 }' <<<"$res" | tr -d '\n') - rm $tmp + mkdir -p "$PASTE_LOG_DIR" + echo "$res" | tee "$PASTE_LOG_DIR/$short" + + if [[ -v DISPLAY ]]; then + xclip -i <<<"$url" + notify-send "pbu" "Copied to clipboard: $url" + fi } # pb delete, takes short id @@ -29,6 +34,17 @@ function pbd() { curl $PB_CURL_ARGS -X DELETE https://$PB_INSTANCE/$short } +function pbi() { + scrot --select --quality 0 /tmp/$$.png + pngcrush -ow /tmp/$$.png + pbu /tmp/$$.png +} + +function pbr() { + asciinema rec /tmp/$$.json + pbu /tmp/$$.json +} + function termbin() { nc termbin.com 9999 } |