From acfd0cdee492131b2ab9fdf073ef93dc9f893c3b Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 17 Jun 2021 22:44:02 +0100 Subject: [PATCH] More escape sequence utilities * Add `tmux-dcs-passthrough` to passthrough escape sequences tmux doesn't understand. * Add `notify` to post a notification via the terminal emulator. --- utilities/utilities.plugin.zsh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/utilities/utilities.plugin.zsh b/utilities/utilities.plugin.zsh index eeaf665..aacc0ff 100644 --- a/utilities/utilities.plugin.zsh +++ b/utilities/utilities.plugin.zsh @@ -15,12 +15,29 @@ elif which xclip &> /dev/null; then fi # Abstract different ways to paste from the clipboard. +# TODO: Use OSC-52 to get the clipboard, not widely supported though if [ "`uname`" = "Darwin" ]; then + # Use pbpaste to get the clipboard alias paste='pbpaste' elif which xclip &> /dev/null; then + # Use xclip to get the clipboard alias paste='xclip -selection c -o' fi +# Passthrough an escape sequences tmux doesn't know about. +tmux-dcs-passthrough() { + if [ -n "$TMUX" ]; then + printf "\x1bPtmux;\x1b$1\x1b\\" + else + printf "$1" + fi +} + +# OSC 9 - Post a notification - supported by iTerm2, maybe others? +notify() { + tmux-dcs-passthrough "\x1b]9;$*\x7" +} + # Detect the type and extract an archive file. extract() { if [ -f $1 ]; then