akavel / up

Ultimate Plumber is a tool for writing Linux pipes with instant live preview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ZSH integration

utdemir opened this issue · comments

This is not an issue per se, but I wrote a small zsh function to integrate up:

zle-upify() {
    buf="$(echo "$BUFFER" | sed 's/[ |]*$//')"
    tmp="$(mktemp)"
    eval "$buf |& up --unsafe-full-throttle -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 '^U' zle-upify

If you add this to your zshrc, Ctrl+U will run up passing the current commands output, and when you exit up with Ctrl+X, the result will replace current prompt. It's slightly easier than dealing with upN.sh files.

It was quite useful for me, I'm just sharing this so maybe you'd like to put it to README.md or somewhere people can find out.

awesome! thx @utdemir

this is fantastic and makes this up so much more convenient, even. It should really be added to the README for people to find more easily.

I'm glad you liked it @chrisgrieser !

I created a new GitHub project with it: utdemir/zsh-up. So now:

  • It can be used with ZSH plugin managers like antigen or zplug without having to copy-paste code.
  • It should be easier to link from the README