summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Höppner2017-05-20 01:12:05 +0200
committerTill Höppner2017-05-20 01:12:05 +0200
commit6767ccf4027455241ab8f1b544ff156fda8b6fc6 (patch)
tree4390f3ec4084e8e68f781df46c95e0fd1031fd49
parent6a97f88019cb43661b09177f270256ab65aaf97e (diff)
downloadzsh-6767ccf4027455241ab8f1b544ff156fda8b6fc6.tar.gz
zsh-6767ccf4027455241ab8f1b544ff156fda8b6fc6.tar.xz
zsh-6767ccf4027455241ab8f1b544ff156fda8b6fc6.zip
Add recording and screenshot function
-rw-r--r--conf.d/99-pastebin.zsh32
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
}