akavel / up

Ultimate Plumber is a tool for writing Linux pipes with instant live preview
Apache License 2.0
8.39k stars 129 forks source link

ZSH integration #44

Open utdemir opened 5 years ago

utdemir commented 5 years ago

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.

kakulukia commented 5 years ago

awesome! thx @utdemir

chrisgrieser commented 2 years ago

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.

utdemir commented 2 years ago

I'm glad you liked it @chrisgrieser !

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