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.
This commit is contained in:
Kenneth Benzie 2021-06-17 22:44:02 +01:00
parent 4561adf530
commit acfd0cdee4

View File

@ -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