From df3c88e64bec3a09507d8d89095c1a57a90292be Mon Sep 17 00:00:00 2001
From: Jens Nolte <jens@nightmarestudio.de>
Date: Mon, 13 Jan 2020 23:15:04 +0100
Subject: [PATCH] Add pastebin function to zsh config

---
 nixos/layers/zsh.nix | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/nixos/layers/zsh.nix b/nixos/layers/zsh.nix
index e796dba..f07b714 100644
--- a/nixos/layers/zsh.nix
+++ b/nixos/layers/zsh.nix
@@ -89,7 +89,7 @@ fi
 
 # "The time the shell waits, in hundredths of seconds, for another key to be pressed when reading bound multi-character sequences."
 # This is for vim-style multi-letter commands (<f><d> is mapped to <Esc>)
-KEYTIMEOUT=10
+KEYTIMEOUT=20
 
 HISTSIZE=100000
 SAVEHIST=100000
@@ -213,5 +213,25 @@ man() {
   LESS_TERMCAP_us=$'\e[01;32m' \
   command man "$@"
 }
+
+# submit file/stdin to pastebin, optionally signing it
+pastebin () {
+    local -r pastebin='https://0x0.st'
+
+    if [ "$1" = '--sign' ]; then
+        local -r filter='gpg --clearsign --output -'
+        shift
+    else
+        local -r filter='cat'
+    fi
+
+    if [ -n "$1" ]; then
+        local -r file="$1"
+    else
+        local -r file='-'
+    fi
+
+    $filter "$file" | curl -F'file=@-' "$pastebin"
+}
   '';
 }
-- 
GitLab