Tmux multi-pane scripting

2012-12-27 Thread El Spliffo
Hi everybody,

i made a script to open automatically my SSH sessions in a few
windows/panes, here it is :

#!/bin/sh
tmux new-session -d -s hawkhost

tmux new-window -t hawkhost:1 -n 'VPN' 'ssh ovpn@10.10.1.70'
tmux new-window -t hawkhost:2 -n 'Halo' 'ssh root@10.10.1.27'
tmux new-window -t hawkhost:3 -n 'Backup-Halo' 'ssh infra@10.10.1.73'
tmux new-window -t hawkhost:4 -n 'Bdd' 'ssh ht@10.10.1.19'
tmux new-window -t hawkhost:5 -n 'DNS' 'ssh -p  ht@10.10.1.79'
tmux new-window -t hawkhost:6 -n 'Ar' 'ssh root@10.10.1.2'
tmux new-window -t hawkhost:7 -n 'Srvdmz' 'ssh root@10.1.0.10'
tmux split-window -h -t hawkhost:6 'ssh root@192.168.1.3'
tmux send-keys -t hawkhost:6.0 '/root/script.sh' C-m
tmux send-keys -t hawkhost:6.1 '/root/script.sh' C-m
tmux select-window -t hawkhost:0
tmux -2 attach-session -t hawkhost

This script is very handy and it allows me to retrieve all my sessions
histories as soon as the tmux process on the server does not end.

My only problem is that the split-window command re-splits my already split
panes, this is not done by the new-window command. Is it possible to avoid
this (if a pane is already split, do not split it on more time, maybe this
should require an id) ?

Thanks very much for any help !
Alex
--
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. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


Re: Tmux multi-pane scripting

2012-12-27 Thread Thomas Adam
Hi,

Look at the FORMATS section in the tmux man page, there's a variable for
the count of panes per window.
On Dec 27, 2012 8:12 AM, "El Spliffo"  wrote:

> Hi everybody,
>
> i made a script to open automatically my SSH sessions in a few
> windows/panes, here it is :
> 
> #!/bin/sh
> tmux new-session -d -s hawkhost
>
> tmux new-window -t hawkhost:1 -n 'VPN' 'ssh ovpn@10.10.1.70'
> tmux new-window -t hawkhost:2 -n 'Halo' 'ssh root@10.10.1.27'
> tmux new-window -t hawkhost:3 -n 'Backup-Halo' 'ssh infra@10.10.1.73'
> tmux new-window -t hawkhost:4 -n 'Bdd' 'ssh ht@10.10.1.19'
> tmux new-window -t hawkhost:5 -n 'DNS' 'ssh -p  ht@10.10.1.79'
> tmux new-window -t hawkhost:6 -n 'Ar' 'ssh root@10.10.1.2'
> tmux new-window -t hawkhost:7 -n 'Srvdmz' 'ssh root@10.1.0.10'
> tmux split-window -h -t hawkhost:6 'ssh root@192.168.1.3'
> tmux send-keys -t hawkhost:6.0 '/root/script.sh' C-m
> tmux send-keys -t hawkhost:6.1 '/root/script.sh' C-m
> tmux select-window -t hawkhost:0
> tmux -2 attach-session -t hawkhost
> 
> This script is very handy and it allows me to retrieve all my sessions
> histories as soon as the tmux process on the server does not end.
>
> My only problem is that the split-window command re-splits my already
> split panes, this is not done by the new-window command. Is it possible to
> avoid this (if a pane is already split, do not split it on more time, maybe
> this should require an id) ?
>
> Thanks very much for any help !
> Alex
>
>
> --
> 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. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122712
> ___
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users
>
>
--
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. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


[tmux:feature-requests] #112 terminal emulation breaks editor "jove" after screen clear command.

2012-12-27 Thread Vivek Khera


---

** [feature-requests:#112] terminal emulation breaks editor "jove" after screen 
clear command.**

**Status:** open
**Created:** Wed Dec 26, 2012 09:52 PM UTC by Vivek Khera
**Last Updated:** Wed Dec 26, 2012 09:52 PM UTC
**Owner:** nobody

When I run my editor, jove, inside tmux, it worked 100% correctly with version 
1.6. With tmux 1.7, however, at times the display update looks like it is in 
overwrite mode even though the editor is in insert mode.

I have made a quick video demonstrating this in action.  The following sequence 
of events demonstrates the error.

1. start tmux
2. edit a file using jove. type some text. it should insert correctly. quit 
jove.
3. type "clear" to clear the screen
4. edit the file using jove. type some text. it now does overwrite of the text 
on screen, but is in fact doing insert on the file. refresh the screen (ctrl-l) 
and it  repaints the full screen and shows the correct content.

In tmux 1.6 this works fine. In tmux 1.7 you see the overwrite effect after the 
"clear".

I've tried all sorts of ways to make it work and make it fail, and I've 
narrowed it down to issuing the "clear" to the terminal inside of tmux 1.7.


I'm running FreeBSD 9 (same happens on 9.0 and 9.1). My shell is tcsh, if that 
matters.

---

Sent from sourceforge.net because you indicated interest in 


To unsubscribe from further messages, please visit 
--
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. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users


Re: Ignoring prefix key special handling when pasting

2012-12-27 Thread Marcin Kulik
This seems to be working great. So far so good.

On Mon, Dec 24, 2012 at 1:21 PM, Nicholas Marriott
 wrote:
> Whoops, try this instead please:
>
> Index: options-table.c
> ===
> RCS file: /cvs/src/usr.bin/tmux/options-table.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 options-table.c
> --- options-table.c 27 Nov 2012 13:52:23 -  1.30
> +++ options-table.c 24 Dec 2012 12:21:00 -
> @@ -91,6 +91,13 @@ const struct options_table_entry server_
>
>  /* Session options. */
>  const struct options_table_entry session_options_table[] = {
> +   { .name = "assume-paste-time",
> + .type = OPTIONS_TABLE_NUMBER,
> + .minimum = 0,
> + .maximum = INT_MAX,
> + .default_num = 1,
> +   },
> +
> { .name = "base-index",
>   .type = OPTIONS_TABLE_NUMBER,
>   .minimum = 0,
> Index: server-client.c
> ===
> RCS file: /cvs/src/usr.bin/tmux/server-client.c,v
> retrieving revision 1.81
> diff -u -p -r1.81 server-client.c
> --- server-client.c 26 Oct 2012 14:35:42 -  1.81
> +++ server-client.c 24 Dec 2012 12:21:01 -
> @@ -34,6 +34,7 @@ void  server_client_check_exit(struct cli
>  void   server_client_check_redraw(struct client *);
>  void   server_client_set_title(struct client *);
>  void   server_client_reset_state(struct client *);
> +intserver_client_assume_paste(struct session *);
>
>  intserver_client_msg_dispatch(struct client *);
>  void   server_client_msg_command(struct client *, struct msg_command_data *);
> @@ -325,6 +326,22 @@ server_client_check_mouse(struct client
> window_pane_mouse(wp, c->session, m);
>  }
>
> +/* Is this fast enough to probably be a paste? */
> +int
> +server_client_assume_paste(struct session *s)
> +{
> +   struct timeval  tv;
> +   u_int   t;
> +
> +   if ((t = options_get_number(&s->options, "assume-paste-time")) == 0)
> +   return 0;
> +
> +   timersub(&s->activity_time, &s->last_activity_time, &tv);
> +   if (tv.tv_sec == 0 && tv.tv_usec < t * 1000)
> +   return 1;
> +   return 0;
> +}
> +
>  /* Handle data key input from client. */
>  void
>  server_client_handle_key(struct client *c, int key)
> @@ -334,7 +351,7 @@ server_client_handle_key(struct client *
> struct window_pane  *wp;
> struct timeval   tv;
> struct key_binding  *bd;
> -   int  xtimeout, isprefix;
> +   int  xtimeout, isprefix, ispaste;
>
> /* Check the client is good to accept input. */
> if ((c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
> @@ -346,6 +363,9 @@ server_client_handle_key(struct client *
> /* Update the activity timer. */
> if (gettimeofday(&c->activity_time, NULL) != 0)
> fatal("gettimeofday failed");
> +
> +   memcpy(&s->last_activity_time, &s->activity_time,
> +   sizeof s->last_activity_time);
> memcpy(&s->activity_time, &c->activity_time, sizeof s->activity_time);
>
> w = c->session->curw->window;
> @@ -382,25 +402,31 @@ server_client_handle_key(struct client *
> }
>
> /* Is this a prefix key? */
> -   if (key == options_get_number(&c->session->options, "prefix"))
> +   if (key == options_get_number(&s->options, "prefix"))
> isprefix = 1;
> -   else if (key == options_get_number(&c->session->options, "prefix2"))
> +   else if (key == options_get_number(&s->options, "prefix2"))
> isprefix = 1;
> else
> isprefix = 0;
>
> +   /* Treat prefix as a regular key when pasting is detected. */
> +   ispaste = server_client_assume_paste(s);
> +   if (ispaste)
> +   isprefix = 0;
> +
> /* No previous prefix key. */
> if (!(c->flags & CLIENT_PREFIX)) {
> -   if (isprefix)
> +   if (isprefix) {
> c->flags |= CLIENT_PREFIX;
> -   else {
> -   /* Try as a non-prefix key binding. */
> -   if ((bd = key_bindings_lookup(key)) == NULL) {
> -   if (!(c->flags & CLIENT_READONLY))
> -   window_pane_key(wp, c->session, key);
> -   } else
> -   key_bindings_dispatch(bd, c);
> +   return;
> }
> +
> +   /* Try as a non-prefix key binding. */
> +   if (ispaste || (bd = key_bindings_lookup(key)) == NULL) {
> +   if (!(c->flags & CLIENT_READONLY))
> +   window_pane_key(wp, s, key);
> +   } else
> +   key_bindings_dispatch(bd, c);
> return;
> }
>
> @@ -413,7 +439,7 @@ server_clien