summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2021-04-02 15:55:01 +0200
committerAlan Pearce2021-04-02 15:55:01 +0200
commitc80002d50f2830d7cda34df311dd6f09649ded63 (patch)
tree4de5595fa5dcf3ff19f5330b1af31d5d939cdcc9 /user
parent96684025aa667ac029c61eed47388a6cdfc16463 (diff)
downloadnixfiles-c80002d50f2830d7cda34df311dd6f09649ded63.tar.lz
nixfiles-c80002d50f2830d7cda34df311dd6f09649ded63.tar.zst
nixfiles-c80002d50f2830d7cda34df311dd6f09649ded63.zip
zsh: install up, interactive pipeline previewer
Diffstat (limited to 'user')
-rw-r--r--user/settings/zsh.nix1
-rw-r--r--user/zsh/zshrc13
2 files changed, 14 insertions, 0 deletions
diff --git a/user/settings/zsh.nix b/user/settings/zsh.nix
index 542d319a..ca13f4d0 100644
--- a/user/settings/zsh.nix
+++ b/user/settings/zsh.nix
@@ -27,6 +27,7 @@ in
     git
     git-lfs
     zsh-completions
+    up
   ];
 
   home.activation.linkOldZshHistory =
diff --git a/user/zsh/zshrc b/user/zsh/zshrc
index b2c76e1a..f9f9c984 100644
--- a/user/zsh/zshrc
+++ b/user/zsh/zshrc
@@ -55,6 +55,19 @@ sort=${commands[gsort]:-$commands[sort]}
 ds () {
   du -hd1 "$@" | $sort -h
 }
+zle-upify() {
+    buf="$(echo "$BUFFER" | sed 's/[ |]*$//')"
+    tmp="$(mktemp)"
+    eval "$buf |& up -o '$tmp' 2>/dev/null"
+    cmd="$(tail -n +2 "$tmp")"
+    rm -f "$tmp"
+    BUFFER="$BUFFER | $cmd"
+    zle end-of-line
+}
+zle -N zle-upify
+
+bindkey '\e^u' zle-upify
+bindkey '\e^p' zle-upify
 
 # returns the first ghq root, whereas $GHQ_ROOT returns all
 hash -d p=$ghq_root[0]