One problem that this solved for me, apart from performance, was easier access to options, and the ability to store private data associated with the session. For instance, one thing i use Lua for is to implement a "raw" mode:
local norm_prefix = tmux.string_to_key("C-a") local norm_prefix2 = tmux.string_to_key("M-/") local alt_prefix = tmux.string_to_key("M-]") function raw_on() local s = tmux.current_session() s:setopt("set-titles-string", "[RAW #S:#I] #T") s:setopt("prefix", alt_prefix) s:setopt("prefix2", alt_prefix) tmux.set("status", "off") s.is_raw = true end function raw_off() local s = tmux.current_session() s:unsetopt("set-titles-string" ) s:unsetopt("prefix") s:unsetopt("prefix2") tmux.set("status", "on") s.is_raw = false end function ctrl_q() local s = tmux.current_session() if s.is_raw then raw_off() else tmux.send("C-q") end end Then in tmux.conf: bind-key -n C-q lcall ctrl_q bind-key = lcall raw_off bind-key g lcall raw_on Then, if i press C-a g, the current client goes into "raw" mode: it changes the prefix key to something I don't use, and turns off the status bar. This is helpful if I ssh to another system from within tmux, then run tmux on the remote system - I can use tmux naturally on the remote system. When I want to escape "raw" mode, I press C-q. If I'm not in raw mode, C-q is passed through. Without Lua, I would have to bind C-q to run a shell script, which makes it difficult to determine if the current session is in "raw" mode: it would have to run "tmux show-options | grep prefix" and parse the output, calling either "tmux set-option" or "tmux send" based on the result. Either way, this is a minimum of three extra processes launching every time I press C-q. When I ran this on my Nokia N900, there was a perceptible delay. The status highlighting, which could easily be separated from the Lua patch, also helps if I run nested tmux sessions - it tells me which tmux instance I'm about to send a command to. On Thu, Aug 8, 2013 at 4:09 PM, Thomas Adam <tho...@xteddy.org> wrote: > Hi, > > On 8 August 2013 21:53, Jared Stafford <jspeng...@jspenguin.org> wrote: >> A while ago I wrote a patch for tmux to add Lua support. This adds a >> bit more flexibility and performance over writing a shell script that >> just runs tmux commands; for instance, you can have lua code that runs >> when a window or session is created or destroyed: > > Can you please look at this and related threads: > > https://sourceforge.net/mailarchive/message.php?msg_id=30723704 > > Because using that as a starting point for potentially using a > scripting language would be easier than your approach, since it's more > generic. > > I don't disagree with your ideals though, but there's much more > thought that needs going in to adding in support for hooks---and > unfortunately while your work helps a little, isn't the full story. > > Note that even if my solution does end up being the one that's used, I > am still in two minds whether or not adding native support for a > direct scripting language is worthwhile when you always have the > ability to just exec some other binary such as lua or python from > whichever hook is invoked at the time. > > Note that on my GitHub account is an example branch of using Lua > against the proposed hook support I've outlined, and is significantly > less work than the amount of Lua-specific code you've needed to write. > > With hook support you need to be very very careful not to add code > bloat, which is why I'm still leaning towards just using sh(1) as the > basis. > > But it's not my decision to make. > > -- Thomas Adam ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users