suppose could update s->cwd on attach but it doesn't do much good if you
switch your client plus if you attach somewhere else then suddenly your
cwd is gone

better might be to use the cmd client cwd, eg try this (untested)

Index: cmd-new-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-window.c,v
retrieving revision 1.49
diff -u -p -r1.49 cmd-new-window.c
--- cmd-new-window.c    7 Jan 2011 14:45:34 -0000       1.49
+++ cmd-new-window.c    18 Jan 2011 16:27:19 -0000
@@ -102,6 +102,8 @@ cmd_new_window_exec(struct cmd *self, st
        if (*cwd == '\0') {
                if (ctx->cmdclient != NULL && ctx->cmdclient->cwd != NULL)
                        cwd = ctx->cmdclient->cwd;
+               else if (ctx->curclient != NULL && ctx->curclient->cwd != NULL)
+                       cwd = ctx->cmdclient->cwd;
                else
                        cwd = s->cwd;
        }




On Tue, Jan 18, 2011 at 02:58:10PM +0000, Julio Merino wrote:
> Hello,
> 
> I am trying to migrate from screen to tmux but I find its "current 
> directory" behavior to be quite irritating.  It actually makes tmux 
> painful to use in my situation.
> 
> My use case: I have a bunch of per-project directories in 
> ~/os/<project>/.  When I want to work on a project, I go into ~/os/foo 
> and start a screen session named "foo".  I do this for several projects 
> at a time so I end up having multiple screen sessions.  Each session has 
> the name of the project it refers to and its current directory is that 
> of the project.  As a result, creating new windows inside each session 
> does the right thing of opening a new shell within the root directory of 
> the corresponding project.
> 
> Now... as you know: in tmux, the current directory for all new windows 
> is set to the directory in which tmux was first started.  Starting a new 
> session when the tmux server is also running has the "funny" effect of 
> correctly creating a new window in the current directory, but any new 
> windows created for that session get the directory of the server.  There 
> is no "per-session current directory" concept.  This, in my opinion, is 
> really confusing.
> 
> What's the rationale behind the current design?
> 
> Could tmux (optionally?) keep the same behavior of screen (that is, to 
> maintain a "current directory" per-session)?
> 
> Thanks!
> 
> PS: I see that this issue was also raised in the "Current directory in 
> new windows/sessions" thread of 2/9/10.  I also see that I could 
> probably achieve something *similar* to what I need by doing some PS1 
> black voodoo (according to the FAQ)... but it's not something that I 
> really fancy.  (And I don't think that such approach is guaranteed to 
> work in non-bash shells.)
> 
> 
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand 
> malware threats, the impact they can have on your business, and how you 
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to