Yes I would be happier with a format for automatic rename, it should not
be hard to do.

pane_current_path is already the WD from osdep_get_cwd, just need
something like pane_current_program and to construct the name using
format in window_name_callback.


On Mon, Dec 10, 2012 at 03:01:05PM -0300, Patricio Palladino wrote:
> Hi!
> 
> On Mon, Dec 10, 2012 at 5:29 AM, Nicholas Marriott
> <nicholas.marri...@gmail.com> wrote:
> > Can you send the patch as a unified diff to the mailing list please?
> 
> Sure, here it is:
> 
> diff --git a/names.c b/names.c
> index 72f1ad1..603ffcf 100644
> --- a/names.c
> +++ b/names.c
> @@ -73,9 +73,18 @@ window_name_callback(unused int fd, unused short
> events, void *data)
>                  * present. Ick.
>                  */
>                 if (w->active->cmd != NULL && *w->active->cmd == '\0' &&
> -                   name != NULL && name[0] == '-' && name[1] != '\0')
> -                       wname = parse_window_name(name + 1);
> -               else
> +                   name != NULL && name[0] == '-' && name[1] != '\0') {
> +                       long long automatic_cwd = options_get_number(
> +                               &w->options,
> +                               "automatic-rename-cwd"
> +                       );
> +
> +                       if (automatic_cwd && w->active->fd != -1) {
> +                               char *cwd = osdep_get_cwd(w->active->fd);
> +                               xasprintf(&wname, "%s", cwd);
> +                       } else
> +                               wname = parse_window_name(name + 1);
> +               } else
>                         wname = parse_window_name(name);
>                 free(name);
>         }
> diff --git a/options-table.c b/options-table.c
> index 4d1edbd..a8d2b3a 100644
> --- a/options-table.c
> +++ b/options-table.c
> @@ -469,6 +469,10 @@ const struct options_table_entry window_options_table[] 
> = {
>           .default_num = 1
>         },
> 
> +    { .name = "automatic-rename-cwd",
> +      .type = OPTIONS_TABLE_FLAG,
> +      .default_num = 0
> +    },
> 
>         { .name = "c0-change-trigger",
>           .type = OPTIONS_TABLE_NUMBER,
> 
> 
> On Mon, Dec 10, 2012 at 5:38 AM, Thomas Adam <tho...@xteddy.org> wrote:
> > and I wouldn't like breaking the toggling aspect of
> > automatic-rename; it's one of those commands that's used surprisingly often
> > by people and breaking that would make users suffer for no real benefit.
> 
> I agree, that's why I created another option.
> 
> > The actual problem this is solving isn't so much about getting the CWD as
> > the title of the window, but *when* it is appropriate to update the title
> > with some value.
> 
> I don't get what you mean here.
> 
> > We already provide #{pane_current_path} in formats, and we could extend this
> > if it's to be some other derived CWD (such as from the window's active FD
> > instead), rather than making this some assumption to be hard-coded.  Then it
> > allows users to use any free-from string they like, without breaking
> > automatic-rename.
> 
> Do you mean adding the ability to set a format for automatic renaming?
> There should be a variable like "default_command" to be able to
> implement this feature, and also the command being executed (as is now
> shown by automatic renaming) to be able to implement this feature with
> a format.
> 
> Having the possibility to add formats to automatic renaming enables
> much interesting options.
> 
> > Guess what will solve this?  Hook support...
> 
> I was kind of surprised when I found that tmux doesn't support hooks.
> Just with a window-name-changed hook fired when the user (not
> automatically) changes the window name would have allow to implement
> this.
> 
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to