-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new-window command functionality #145
Conversation
I tried to see if I could figure out how to add a test for it, but it didn't seem to work. :\ |
@@ -124,7 +124,8 @@ def new_window(self, | |||
window_name=None, | |||
start_directory=None, | |||
attach=True, | |||
window_index=''): | |||
window_index='', | |||
window_command=None): | |||
"""Return :class:`Window` from ``$ tmux new-window``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the docstrings (:param window_index: description
, so on) for these params?
The code you added will only run the command once on building the workspace, after that, any new panes/windows won't be run with this command. This functionality was already available though Maybe you want to add tmux key bindings? That will let any new windows/panes you open run a given command when they open. In order to have the whole session live inside a virtual environment, including any new windows, you can use |
Can you clarify who / what this refers to? Just double checking @kmactavish giving this and #146 a look tomorrow/sat. You're on a roll! |
I understand what you're saying, but this code is the functionality I'm looking for. I have a configuration where there are some windows which should load the virtual environment, and others which don't. (In my case, it's a directory for a static_files system separate from the virtual environment's project directory.) Adding a |
Hmm, I see. Did you want the functionality for the API, or for building a session? I think it makes sense for the API, but maybe not the Right now, in the I see three potential problems for using a
@tony P.S. that comment was me missunderstanding what @ikirudennis was trying to accomplish, which I may still be doing 😉 . |
BTW, what is the |
Yes, I did a test with a command which exits quickly, and yes it produces an error. In my setup, I'm loading a virtualenvironment via pew. Pew works a little differently in that it starts a new shell instead of injecting the virtualenv into an existing shell. The reason I dislike |
Gotcha. You've won me over, and I like the fact that it's an undocumented feature---there is no example for it, so it won't be confusing for new users. Since people will only find it if they look at the unit test or in workspace builder, maybe comment in both those places its intended use and perils 😉 . |
P.S. |
I tried to fix the test, but it seemed to only break things on my computer.
Though I'm not sure if this is the right fix.
for w, wconf in builder.iter_create_windows(s): | ||
if 'window_shell' in wconf: | ||
self.assertEqual(wconf['window_shell'], text_type('test_command')) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are intended to be integration tests in the truest sense of the word. See .travis.yml
.
We have a minimum tmux version we officially support (though we can bump it of course). I'd like to be sure that this behavior would work on older versions.
Try something like this:
diff --git a/tmuxp/testsuite/workspacebuilder.py b/tmuxp/testsuite/workspacebuilder.py
index 253834e..a8b79dc 100644
--- a/tmuxp/testsuite/workspacebuilder.py
+++ b/tmuxp/testsuite/workspacebuilder.py
@@ -266,7 +266,7 @@ class WindowOptions(TmuxTestCase):
- pane
- pane
window_name: editor
- window_shell: test_command
+ window_shell: top
"""
s = self.session
sconfig = kaptan.Kaptan(handler='yaml')
@@ -277,7 +277,14 @@ class WindowOptions(TmuxTestCase):
for w, wconf in builder.iter_create_windows(s):
if 'window_shell' in wconf:
- self.assertEqual(wconf['window_shell'], text_type('test_command'))
+ self.assertEqual(wconf['window_shell'], text_type('top'))
+ for i in range(10):
+ self.session.server._update_windows()
+ if w['window_name'] != 'top':
+ break
+ time.sleep(.2)
+
+ self.assertNotEqual(w.get('window_name'), text_type('top'))
class EnvironmentVariables(TmuxTestCase):
@@ -305,7 +312,7 @@ class EnvironmentVariables(TmuxTestCase):
self.assertEqual('BAR', self.session.show_environment('FOO'))
self.assertEqual('/tmp', self.session.show_environment('PATH'))
-
+
class WindowAutomaticRename(TmuxTestCase):
yaml_config = """
…ash_history Optionally disable shell history suppression
...in accordance with the prophecy.
Can you rebase against master and squash? |
Hmm, that is strange. It is correct in identifying that as a test failure, The only thing I can think of is that when the pane was captured, it hadn't finished being initialized, and the If that's seen again, I can submit this patch. diff --git a/tmuxp/testsuite/workspacebuilder.py b/tmuxp/testsuite/workspacebuilder.py
index 79b5329..206f52e 100644
--- a/tmuxp/testsuite/workspacebuilder.py
+++ b/tmuxp/testsuite/workspacebuilder.py
@@ -238,7 +238,7 @@ class SuppressHistoryTest(TmuxTestCase):
builder = WorkspaceBuilder(sconf=sconfig)
builder.build(session=self.session)
- time.sleep(0.2) # give .bashrc, etc. time to load
+ time.sleep(0.3) # give .bashrc, etc. time to load
s.server._update_windows()
for w in s.windows:
@@ -250,7 +250,7 @@ class SuppressHistoryTest(TmuxTestCase):
# Print the last-in-history command in the pane
self.session.cmd('send-keys', ' fc -ln -1')
self.session.cmd('send-keys', 'Enter')
- time.sleep(0.01) # give fc time to run
+ time.sleep(0.1) # give fc time to run
# Get the contents of the pane
self.session.cmd('capture-pane') References #146 . |
@kmactavish Yep, that'll give travis a bit more breathing room. Can you rebase against master and squash too? Once that's good we can merge |
I tried to fix the test, but it seemed to only break things on my computer.
Though I'm not sure if this is the right fix.
...in accordance with the prophecy.
…o new-window-command
I hope I did that right. |
re: squashing, I meant to direct that to @ikirudennis. It seems GH has a "squash and merge" available after you hit "Merge Pull Request". |
See issue #142