From 543e7b0f03f2c41752ec2e244e26c525a4791cb8 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 19 Oct 2007 17:15:29 +0000 Subject: [PATCH] -n is now -s on new-session. --- CHANGES | 4 ++- TODO | 1 + cmd-new-session.c | 25 +++++++++++++++---- cmd-rename-window.c | 4 +-- .../{start-tmux.sh => mxey-start-tmux.sh} | 2 +- examples/nicm-start-tmux.sh | 24 ++++++++++++++++++ 6 files changed, 51 insertions(+), 9 deletions(-) rename examples/{start-tmux.sh => mxey-start-tmux.sh} (84%) mode change 100755 => 100644 create mode 100644 examples/nicm-start-tmux.sh diff --git a/CHANGES b/CHANGES index ff2d481b..7a3ef909 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ 19 October 2007 +* (nicm) -n on new-session is now -s, and -n is now the initial window name. + This was documented but not implemented :-/. * (nicm) kill-window command, bound to & by default (because it should be hard to hit accidently). * (nicm) bell-style option with three choices: "none" completely ignore bell; @@ -137,5 +139,5 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.44 2007-10-19 11:10:34 nicm Exp $ +$Id: CHANGES,v 1.45 2007-10-19 17:15:28 nicm Exp $ diff --git a/TODO b/TODO index d3f9f521..d8b3ad72 100644 --- a/TODO +++ b/TODO @@ -43,6 +43,7 @@ - it would be nice to have multichar commands so you could have C-b K K for kill-window to limit accidental presses - status-fg/status-bg should be to set attributes: bold, etc +- show-options command -- For 0.1 -------------------------------------------------------------------- - man page diff --git a/cmd-new-session.c b/cmd-new-session.c index 69fad293..80f77490 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.12 2007-10-19 09:21:25 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.13 2007-10-19 17:15:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,12 +34,14 @@ void cmd_new_session_free(void *); struct cmd_new_session_data { char *name; + char *winname; char *cmd; int flag_detached; }; const struct cmd_entry cmd_new_session_entry = { - "new-session", "new", "[-d] [-n session name] [command]", + "new-session", "new", + "[-d] [-s session name] [-n window name] [command]", CMD_STARTSERVER|CMD_NOSESSION|CMD_CANTNEST, cmd_new_session_parse, cmd_new_session_exec, @@ -57,16 +59,20 @@ cmd_new_session_parse(void **ptr, int argc, char **argv, char **cause) *ptr = data = xmalloc(sizeof *data); data->flag_detached = 0; data->name = NULL; + data->winname = NULL; data->cmd = NULL; - while ((opt = getopt(argc, argv, "dn:")) != EOF) { + while ((opt = getopt(argc, argv, "ds:n:")) != EOF) { switch (opt) { case 'd': data->flag_detached = 1; break; - case 'n': + case 's': data->name = xstrdup(optarg); break; + case 'n': + data->winname = xstrdup(optarg); + break; default: goto usage; } @@ -92,7 +98,8 @@ usage: void cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx) { - struct cmd_new_session_data *data = ptr, std = { NULL, NULL, 0 }; + struct cmd_new_session_data *data = ptr; + struct cmd_new_session_data std = { NULL, NULL, NULL, 0 }; struct client *c = ctx->client; char *cmd; u_int sy; @@ -125,6 +132,10 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx) c->session = session_create(data->name, cmd, c->sx, sy); if (c->session == NULL) fatalx("session_create failed"); + if (data->winname != NULL) { + xfree(c->session->window->name); + c->session->window->name = xstrdup(data->winname); + } if (data->flag_detached) server_write_client(c, MSG_EXIT, NULL, 0); @@ -141,6 +152,7 @@ cmd_new_session_send(void *ptr, struct buffer *b) buffer_write(b, data, sizeof *data); cmd_send_string(b, data->name); + cmd_send_string(b, data->winname); cmd_send_string(b, data->cmd); } @@ -152,6 +164,7 @@ cmd_new_session_recv(void **ptr, struct buffer *b) *ptr = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); data->name = cmd_recv_string(b); + data->winname = cmd_recv_string(b); data->cmd = cmd_recv_string(b); } @@ -162,6 +175,8 @@ cmd_new_session_free(void *ptr) if (data->name != NULL) xfree(data->name); + if (data->winname != NULL) + xfree(data->winname); if (data->cmd != NULL) xfree(data->cmd); xfree(data); diff --git a/cmd-rename-window.c b/cmd-rename-window.c index dea632a8..fab15f32 100644 --- a/cmd-rename-window.c +++ b/cmd-rename-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-window.c,v 1.6 2007-10-19 09:21:26 nicm Exp $ */ +/* $Id: cmd-rename-window.c,v 1.7 2007-10-19 17:15:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -39,7 +39,7 @@ struct cmd_rename_window_data { }; const struct cmd_entry cmd_rename_window_entry = { - "rename-window", "renamew", "[-i index] newname", + "rename-window", "renamew", "[-i index] new name", 0, cmd_rename_window_parse, cmd_rename_window_exec, diff --git a/examples/start-tmux.sh b/examples/mxey-start-tmux.sh old mode 100755 new mode 100644 similarity index 84% rename from examples/start-tmux.sh rename to examples/mxey-start-tmux.sh index ee21057c..fb062276 --- a/examples/start-tmux.sh +++ b/examples/mxey-start-tmux.sh @@ -2,7 +2,7 @@ tmux attach if [[ $? = 1 ]]; then - tmux new-session -d -nmain 'exec irssi' + tmux new-session -d -smain 'exec irssi' tmux -smain set prefix '^H' tmux -smain new-window -d -nherrie 'exec sudo herrie -c /home/mxey/etc/herrie/config' tmux -smain new-window -d 'exec lynx' diff --git a/examples/nicm-start-tmux.sh b/examples/nicm-start-tmux.sh new file mode 100644 index 00000000..d58afcdb --- /dev/null +++ b/examples/nicm-start-tmux.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +SOCKET=/tmp/tmux-1000-main +SESSION=natasha-main + +TMUX="tmux -S $SOCKET" + +if ! $TMUX -s $SESSION attach 2>/dev/null; then + $TMUX new -d -s $SESSION -nyelena 'exec ssh yelena' # 0 + $TMUX -s $SESSION neww -d -ntodo 'exec emacs ~/TODO' # 1 + $TMUX -s $SESSION neww -d -nncmpc 'exec ncmpc -f ~/.ncmpc.conf' # 2 + $TMUX -s $SESSION neww -d # 3 + $TMUX -s $SESSION neww -d # 4 + $TMUX -s $SESSION neww -d # 5 + $TMUX -s $SESSION neww -d # 6 + $TMUX -s $SESSION neww -d # 7 + $TMUX -s $SESSION neww -d # 8 + $TMUX -s $SESSION neww -d # 9 + + $TMUX set prefix ^A + $TMUX set bell-action none + + $TMUX -s $SESSION attach +fi