Re: Confusion about window names and pane titles

2011-12-09 Thread Felix Rosencrantz
I've attached a proposed patch to the man page, that updates the
details described in this thread.

Thanks.
-FR.

On Thu, Nov 3, 2011 at 5:19 PM, Nicholas Marriott
 wrote:
> On Thu, Nov 03, 2011 at 02:57:40PM -0700, Felix Rosencrantz wrote:
>> I was having a problem where my window names were disappearing when my shell
>> started, at first I was thinking the problem was related to the
>> automatic-renaming option.  After some investigation, the problem was that my
>> prompt was sending a code "\033k\033\\", which is used to clear screen's 
>> title,
>> there is a note about this in the comments in input.c.
>>
>> One problem that made this difficult to track down was that the manual page 
>> is
>> not very precise, and particular details are omitted.  It's not clear to me 
>> from
>> the man page that windows and panes have their own separate title/names.
>> Though here is what I think the state of tmux is:
>>    Windows have names which can be set in one of three ways:
>>    1) By tmux command (e.g. new-window, new-session, or rename-window)
>>    2) By escape code (e.g. printf '\033kWINDOW_NAME\033\\")
>>    3) Automatic renaming, which tries to be the active command in the
>>       active pane of the window.
>
> yes this is correct
>
> personally i don't like that escape sequence, it is a gnu screen
> extension, should try to find something more sensible instead. maybe
> \033]1, not sure what xterm uses that for
>
> i'm not sure if we should document specific escape sequences, although
> if you're adding a section on naming and titles it'd make sense to cover
> these i suppose
>
>>    4) Man page issues:
>>       1) doesn't mention escape code, and that escape code turns off
>> automatic rename
>>       2) automatic-renaming isn't specific about which pane is used.
>>       3) The status-left option mentions both a window title&name. Here 
>> window
>>          title, is actually the active pane title.
>>    Panes have titles, which can be set one way:
>>    1) By escape code: printf '\033]2;My Title\033\\'
>
> yes that's right
>
> title is what would typically be displayed in the xterm window title in
> a window manager
>
>>    2) Man page issues:
>>       1) says escape code is used for "window title"
>>       2) The FORMATS section lists "pane_title", but otherwise not
>> mentioned in man page.
>>    3) FAQ incorrectly states: * tmux panes do not have individual
>> names, titles and so on.
>>    Clients have a title, used to set xterm titles,
>>    1) Can only be specified by tmux command set-titles-string
>>    2) Documentation issues:
>>       1) The man page isn't very clear set-titles-string applies to clients
>>
>>
>> I may still be confused, so would like to confirm if this correct.  It seems
>> like it would be useful if details about names&title were more precisely
>> spelled out in a separate man page section.
>>
>> -FR.
>>
>> --
>> RSA(R) Conference 2012
>> Save $700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> ___
>> tmux-users mailing list
>> tmux-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/tmux-users
--- tmux.1.orig	2011-12-09 09:06:40.568409143 -0800
+++ tmux.1	2011-12-09 08:56:42.828410291 -0800
@@ -2110,7 +2114,7 @@
 .It Li "#I" Ta "Current window index"
 .It Li "#P" Ta "Current pane index"
 .It Li "#S" Ta "Session name"
-.It Li "#T" Ta "Current window title"
+.It Li "#T" Ta "Current pane title"
 .It Li "#W" Ta "Current window name"
 .It Li "##" Ta "A literal" Ql #
 .El
@@ -2129,13 +2133,9 @@
 .Sx ENVIRONMENT
 section).
 .Pp
-The window title (#T) is the title set by the program running within the window
-using the OSC title setting sequence, for example:
-.Bd -literal -offset indent
-$ printf '\e033]2;My Title\e033\e\e'
-.Ed
-.Pp
-When a window is first created, its title is the hostname.
+For details on how the names and titles can be set see the 
+.Sx "NAMES AND TITLES"
+section.
 .Pp
 #[attributes] allows a comma-separated list of attributes to be specified,
 these may be
@@ -2654,6 +2654,57 @@
 .It Li "window_name" Ta "Name of window"
 .It Li "window_width" Ta "Width of window"
 .El
+.Sh NAMES AND TITLES
+.Nm
+allows sessions, clients, windows and panes to have a name or a
+title.
+A name is used for specifying targets in commands and
+for display.
+A title is used only as output of list commands or status lines.
+The following rules describe how titles and names are
+created and modified.
+.Pp
+A session has a name which can be set by the commands
+.Ic new-session
+and
+.Ic rename-session .
+.Pp
+A client has a title, which can be set by the
+.Ic set-titles-string
+option.  A client title is only displayed as the the xterm title of the 
+terminal holding a client.  In commands,
+.Ar target-client
+is the name of
+the
+.Xr pty 4
+file to which the client is connected.
+.Pp
+A window has a name, which can be se

Re: [PATCH] New option to get cwd of new windows from active window

2011-12-09 Thread Nicholas Marriott
Thanks for this. The OpenBSD kernel bits are in so I've applied your
diff with some minor tweaks and the required bits for osdep-openbsd.c.

Anyone wants to do AIX, Darwin, DFLY, HP/UX, or NetBSD send the code
:-).



On Tue, Dec 06, 2011 at 07:35:18PM +0100, Romain Francoise wrote:
> Nicholas Marriott  writes:
> 
> > Ok, so OpenBSD should have a way to do this soon, either a new
> > second-level sysctl KERN_PROC_CWD or a new third-level under
> > KERN_PROC_ARGS. Don't worry about that though, let's move forward with
> > your diff and I'll add OpenBSD when my code goes in.
> 
> Awesome, thanks.
> 
> Here's a v2 patch with the following changes:
> - logic updated as per your suggestion (note, default-path already
>   defaults to "")
> - support for FreeBSD, tested on FreeBSD 8.2
> - support for Solaris, untested but it's similar to Linux
> - doc updated for 'default-path'
> 
> diff --git a/cmd-new-window.c b/cmd-new-window.c
> index 065e2b1..30ddd64 100644
> --- a/cmd-new-window.c
> +++ b/cmd-new-window.c
> @@ -98,13 +98,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
>   cmd = options_get_string(&s->options, "default-command");
>   else
>   cmd = args->argv[0];
> - cwd = options_get_string(&s->options, "default-path");
> - if (*cwd == '\0') {
> - if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
> - cwd = ctx->cmdclient->cwd;
> - else
> - cwd = s->cwd;
> - }
> + cwd = cmd_get_default_path(ctx);
>  
>   if (idx == -1)
>   idx = -1 - options_get_number(&s->options, "base-index");
> diff --git a/cmd-split-window.c b/cmd-split-window.c
> index 258c632..7089193 100644
> --- a/cmd-split-window.c
> +++ b/cmd-split-window.c
> @@ -77,13 +77,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx 
> *ctx)
>   cmd = options_get_string(&s->options, "default-command");
>   else
>   cmd = args->argv[0];
> - cwd = options_get_string(&s->options, "default-path");
> - if (*cwd == '\0') {
> - if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
> - cwd = ctx->cmdclient->cwd;
> - else
> - cwd = s->cwd;
> - }
> + cwd = cmd_get_default_path(ctx);
>  
>   type = LAYOUT_TOPBOTTOM;
>   if (args_has(args, 'h'))
> diff --git a/cmd.c b/cmd.c
> index 2027f75..a1b96c3 100644
> --- a/cmd.c
> +++ b/cmd.c
> @@ -1212,3 +1212,31 @@ cmd_template_replace(char *template, const char *s, 
> int idx)
>  
>   return (buf);
>  }
> +
> +/*
> + * Return a default path for new windows appropriate for this command
> + * context.
> + */
> +char *
> +cmd_get_default_path(struct cmd_ctx *ctx)
> +{
> + char*cwd;
> + struct session  *s;
> + struct window_pane  *wp;
> +
> + if ((s = cmd_current_session(ctx, 0)) == NULL)
> + return (NULL);
> +
> + cwd = options_get_string(&s->options, "default-path");
> + if (*cwd == '\0') {
> + if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
> + return (ctx->cmdclient->cwd);
> + if (ctx->curclient != NULL) {
> + wp = s->curw->window->active;
> + if ((cwd = osdep_get_pid_cwd(wp->pid)) != NULL)
> + return (cwd);
> + }
> + return (s->cwd);
> + }
> + return (cwd);
> +}
> diff --git a/osdep-aix.c b/osdep-aix.c
> index 0dc07d6..02a650d 100644
> --- a/osdep-aix.c
> +++ b/osdep-aix.c
> @@ -28,6 +28,12 @@ osdep_get_name(unused int fd, unused char *tty)
>   return (NULL);
>  }
>  
> +char *
> +osdep_get_pid_cwd(pid_t pid)
> +{
> + return (NULL);
> +}
> +
>  struct event_base *
>  osdep_event_init(void)
>  {
> diff --git a/osdep-darwin.c b/osdep-darwin.c
> index 229a493..092adde 100644
> --- a/osdep-darwin.c
> +++ b/osdep-darwin.c
> @@ -48,6 +48,12 @@ osdep_get_name(int fd, unused char *tty)
>   return (strdup(kp.kp_proc.p_comm));
>  }
>  
> +char *
> +osdep_get_pid_cwd(pid_t pid)
> +{
> + return (NULL);
> +}
> +
>  struct event_base *
>  osdep_event_init(void)
>  {
> diff --git a/osdep-dragonfly.c b/osdep-dragonfly.c
> index b15abf9..6cb656f 100644
> --- a/osdep-dragonfly.c
> +++ b/osdep-dragonfly.c
> @@ -119,6 +119,12 @@ error:
>   return (NULL);
>  }
>  
> +char *
> +osdep_get_pid_cwd(pid_t pid)
> +{
> + return (NULL);
> +}
> +
>  struct event_base *
>  osdep_event_init(void)
>  {
> diff --git a/osdep-freebsd.c b/osdep-freebsd.c
> index 6b0c888..077a2c0 100644
> --- a/osdep-freebsd.c
> +++ b/osdep-freebsd.c
> @@ -29,9 +29,11 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  struct kinfo_proc*cmp_procs(struct kinfo_proc *, struct kinfo_proc *);
>  char *osdep_get_name(int, char *);
> +char *osdep_get_pid_cwd(pid_t);
>  struct event_base*osdep_event_init(void);
>  
>

Re: set-titles not working

2011-12-09 Thread Josh Audette
On Thu, Dec 08, 2011 at 01:21:55AM +, Nicholas Marriott wrote:
> No it looks fine. So what's happening? you turn on set-titles but tmux
> does not change the title? Can your run tmux -v for a bit then
> kill it and send me the logs?

Logged out of all currently running tmuxes, then ran:

tmux -v

... from a fresh xterm.  Did "vi foo" from it, then exited, and logged
out.

I think I see in tmux-out-10358.log that it did try to write the title,
but I'm not knowledgeable enough to know if it is doing so correctly or
why it didn't work.

Logs are attached in logs.tar.bz2


Best regards,
Josh Audette


logs.tar.bz2
Description: Binary data
--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/___
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users