I considered at one point being able to set rules for running commands based on
the window title, although this would be a another case where it would be nice
to have hooks and an if command.



On Wed, Jan 27, 2010 at 10:48:03PM -0800, Micah Cowan wrote:
> Micah Cowan wrote:
> > So, I recently discovered that if automatic window-renaming is on
> > (default), it's possible for a program's name to influence how the
> > window is rendered in the status bar[...]
> 
> Here's a slightly more easily-extensible version of that program,
> written in Python (2.6 or higher; works in 3.x). The values set in the
> attr dictionary work best in 256-color mode.
> 
> ----------------------------------------------------------------
> #!/usr/bin/env python
> 
> from __future__ import print_function, division, unicode_literals
> 
> import sys
> import os
> 
> attr = {}
> attr['vim'] = 'fg=colour90'
> attr['ssh'] = 'fg=colour28'
> 
> def spawn(prog, args):
>     os.execvp(prog, args)
>     print("Can't exec: %s" % os.strerr(os.errno), file=sys.stderr)
>     sys.exit(1)
> 
> 
> if len(sys.argv) <= 1:
>     sys.exit(1)
> 
> args = sys.argv[1:]
> 
> if len(args) == 1 or "TMUX" not in os.environ:
>     spawn(args[0], args)
> 
> progname = args[0]
> arg0     = args[0]
> del(args[0])
> 
> if progname in attr:
>     arg = None
>     for a in args:
>         if len(a) > 0 and a[0] != '-':
>             arg = a.rsplit('/', 1)[-1]
>             if arg == '': arg = None
>             break
>     if arg is not None:
>         arg0 = '#[' + attr[progname] + ']' + arg + '#[default]'
> 
> spawn(progname, [arg0] + args)
> ----------------------------------------------------------------
> 
> If you drop it somewhere in your path as "wtitle" (after setting
> executable permissions), and add the following to your ~/.bashrc or
> whatever, then you get some better (IMHO) auto-titling behavior for vim
> and ssh under tmux:
> 
> ----------------------------------------------------------------
> if test -n "${TMUX-}" && command -v wtitle >/dev/null 2>&1
> then
>     alias vim='wtitle vim'
>     alias ssh='wtitle ssh'
> fi
> ----------------------------------------------------------------
> 
> Cheers!
> 
> -- 
> Micah J. Cowan
> http://micah.cowan.name/
> 
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to