Re: monitor-content matches

2010-05-31 Thread Vincent Wang
you can try 'pipe-pane', pls read tmux's manpage to get more details.

I use it to check if tests are finished, send a notification(growl) to
me, and it works very well. 

* clemens fischer  [2010-05-30 17:16:06 
+0200]:

> 'uname -rims' -> Linux 2.6.33.4-spott i686 AuthenticAMD
> tmux-CVS from today
> 
> Hi,
> 
> I have these settings in ".tmux.conf":
> 
> set-window-option -g monitor-content '[0-9]* [0-9]* [#$] ?'
> set-option -g visual-content on
> 
> designed to match my shells prompt[1] looking like this:  "0 4 # ".  The
> first number is the exit status of the last command, then comes the PTY
> number and then "#" for root and "$" for a regular user, a space and
> there's the bash waiting for input.
> 
> Tmux flags content as soon as anything is printed to screen, not only
> this prompt.  Linux has fnmatch(3), I see it is used without any flags
> every place, shouldn't it match _new_ content only?  In
> "window.c::window_pane_search()" it is used on every line on the screen
> (without history, it seems).  But why doesn't it trigger as soon as any
> prompt is seen, ie.  immediately?
> 
> [1]
> 1 4 # echo "${PS1}"
> \w\n${_last_status} ${_this_pty} \$
> 
> 
> clemens
> 
> 
> --
> 
> ___
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

-- 
"The tool that save the most labor in a programming project is probably a 
text-editing system"  -- <>

http://blog.linsong.org

--

___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


Re: monitor-content matches

2010-05-31 Thread Vincent Wang
* clemens fischer  [2010-05-31 15:58:09 
+0200]:

> 
> It takes a while before getting used to the scriptability of tmux
> lacking in screen.

Yeah, tmux should provide more command to support scripting, that is
very useful.

> 
> I was going to suggest a feature:
> 
>   Allow to associate a tag, consiting of a single letter, either at the
>   current position of the cursor or its position in the history when in
>   copy-mode.  Fit the "monitor-content" option with a variant that lets
>   the user restrict the search space by tag[s].  There could be a pseudo
>   tag meaning "from-here".
> 
> With your suggestion this feature isn't necessary.  The only problem
> people may have is the restriction of only one open pipe per pane, so
> one can have either logging or notification, not both.

I wrote a very simple ruby script that define a action map, regex as
key, a function as value, so you can define as many different actions
as you need based on regex, that can solve the problem. 

> 
> 
> clemens
> 
> 
> --
> 
> ___
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

-- 
"There are very few problems in Computer Science that cannot be solved with an 
additional level of indirection." 

http://blog.linsong.org

--

___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


Re: monitor-content matches

2010-06-02 Thread Vincent Wang
* clemens fischer  [2010-06-01 17:30:36 
+0200]:

> Vincent Wang wrote:
> 
> > I wrote a very simple ruby script that define a action map, regex as
> > key, a function as value, so you can define as many different actions
> > as you need based on regex, that can solve the problem. 
> 
> You mean actions triggered by window-content?  Can you post it or send
> by private email?

Here is it:

#! /usr/bin/env ruby

event_hash = {
  /^=> Ctrl-C to shutdown server/ => lambda { ["Rails started"] },
  /^(\d+ tests, \d+ assertions, \d+ failures, \d+ errors)/ => lambda { [$1, 
"Ruby Test"] },
}

def notify(msg, title="Notification") 
  system(%Q{/usr/local/bin/growlnotify --image ~/Desktop/mylogo.png -n 
"ShellNotification" -m "#{msg}" "#{title}" 2>/dev/null;}) 
end

ARGF.each do |line|
  event_hash.each_pair do |k, v|
notify(*v.call) if line =~ k
  end
end

You need to copy these lines into a file(for example notification.rb) and make 
it executable or you can use the file in attachment.

BR
Vincent

> 
> 
> clemens
> 
> 
> --
> 
> ___
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

-- 
"There are very few problems in Computer Science that cannot be solved with an 
additional level of indirection." 

http://blog.linsong.org
#! /usr/bin/env ruby

event_hash = {
  /^=> Ctrl-C to shutdown server/ => lambda { ["Rails started"] },
  /^(\d+ tests, \d+ assertions, \d+ failures, \d+ errors)/ => lambda { [$1, 
"Ruby Test"] },
}

def notify(msg, title="Notification") 
  system(%Q{/usr/local/bin/growlnotify --image ~/Desktop/mylogo.png -n 
"ShellNotification" -m "#{msg}" "#{title}" 2>/dev/null;}) 
end

ARGF.each do |line|
  event_hash.each_pair do |k, v|
notify(*v.call) if line =~ k
  end
end
--

___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users