Dear urxvt and tmux communities,

Attached is a snippet which escapes my tmux prefix character ` by replacing it
by `` whenever I paste text into tmux. This is detected by matching the window
title for /^tmux /. It can be easily adapted to different window titles and
prefix characters. I'm posting it to these lists for discussion and so that it
doesn't get lost and can be found by search engines.

It's a rather trivial script with all values hardcoded (regex to match if tmux
is running, prefix character, no detection for nested tmux instances, etc.) but
a classical case of "works for me".

A copy of the script can also be obtained here:
http://barfooze.de/stuff/urxvt/tmux-paste-helper

Please feel free to proceed with it as you please.


Best regards,

Moritz
#!/usr/bin/env perl
# Written 2011 by Moritz Wilhelmy, mw aett wzff dot de
# 
# This file is hereby placed in the public domain. There is no warranty.
#
# urxvt perl extension to escape tmux prefix character, i.e. replace all
# occurrences of ` by `` when pasting into tmux (detected by matching the window
# title) for convenience.


sub on_tt_paste {
        my ($term, $paste) = @_;

        my ($type, $format, $wintitle) = 
                $term->XGetWindowProperty($term->parent, 
$term->XInternAtom("WM_NAME"));

        $paste =~ s/`/``/g if $wintitle =~ m/^tmux /;

        $term->tt_paste($paste);

        1
}
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to