Skip to content
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

Exit tmuxinator project session #92

Closed
vighnesh1987 opened this issue Jan 18, 2013 · 26 comments
Closed

Exit tmuxinator project session #92

vighnesh1987 opened this issue Jan 18, 2013 · 26 comments

Comments

@vighnesh1987
Copy link

It'd be neat to have a feature which allows you to exit a tmuxinator project session safely i.e.
for a pane running vim, it first does a :qa, followed by a to close the pane,
for a pane running a server, it does a followed by

The exact commands could be specified in the project yaml file.

Comments?

@klaut
Copy link

klaut commented May 11, 2013

+1

@philipsahli
Copy link

It would be great if tmuxinator is closing files opened with vi. IMO that could be a default behaviour.

@sebastibe
Copy link

In the same related feature, having a post parameter similar to pre to trigger some events before closing the session would be really great.

@ghost
Copy link

ghost commented Jun 21, 2013

This seems like a popular feature that I'd really want to add. However the way tmux wrappers work typically (including tmuxinator) is outputting a set of shell commands that starts the tmux session, attaching you to the started session and then exiting. tmuxinator has then no knowledge of the tmux process.

Because of this, as far as I can see, there are two ways to approach this given the way tmux works:

  • Have a persistent process that runs in the background that can monitor the state of active tmux sessions and run the specified commands when a pane / window gets closed. This would be a lot of work and I really wouldn't want to go down this route. (I'd love to be proven otherwise; pull requests welcome).
  • An alternative would be to close sessions via a tmuxinator close window <name> or tmuxinator close pane command. This could work but is quite a bit more cumbersome.

If anyone else has suggestions I'd love to hear other ways to to tackle this.

@xntrik
Copy link

xntrik commented Jul 13, 2013

Perhaps you could have a new hash config item under the tabs hash that specifies exit key-presses for how to quit that particular window? Then a separate tmux command to issue the various tmux send-keys. (I don't know if this is any more graceful than what you suggested, but, at least it's customisable).

Example:

tabs:
    - shell:
        panes:
            - #
        exit:
            - exit Enter
    - server:
        panes:
            - rails s
        exit:
            - C-c
            - exit Enter
    - database:
        panes:
            - rails db
        exit:
            - .quit Enter
            - exit Enter

So if the session was called APP, then you'd just have to wrap together a bunch of commands similar to:
tmux send-keys -t APP:shell exit Enter
tmux send-keys -t APP:server C-c
tmux send-keys -t APP:server exit Enter
tmux send-keys -t APP:database .quit Enter
tmux send-keys -t APP:database exit Enter

@xntrik
Copy link

xntrik commented Jul 16, 2013

Wow.. sorry, the 'space indentation' I had in that comment did not apparently come through at all :(

@ghost
Copy link

ghost commented Jul 17, 2013

That's not a bad idea @xntrik. It'd have to be a top level item in the config though: So:

tabs:
  - editor: vim
  - logs: tail -f log/development.log
  - console:
    panes:
      - bundle exec rails console
      - mysql database
post_tab:
  - editor: :wq
  - logs: C-c
  - console:
    panes:
      - exit
      - \q

This would close all applications provided each pane/window had the process running in them. After that we can close all the windows via tmux kill-window or tmux kill-pane.

Couple of things though:

  • If a process doesn't exit cleanly because the specified exit command didn't work for some reason, the process will be killed ungracefully once the kill pane/window command is issued
  • If post_tab is defined, exit commands would have to be provided for all panes/windows.

Thoughts?

@xntrik
Copy link

xntrik commented Jul 18, 2013

I think that looks pretty good.

I can't imagine many people would actually use this functionality. I guess it's whether or not you'd see this method is better than having no method.

@chibicode
Copy link

@Soliah @xntrik 👍

I edit the config yml files often, and every time I do, I'd like to start fresh by killing the edited project and restarting it. So this would be very useful for me.

@ghost
Copy link

ghost commented Aug 6, 2013

I'm gonna tag this for 0.8.0. It'll require a bit more thought but I think it is doable.

@amaltson
Copy link

amaltson commented Aug 7, 2013

👍 for post_tab, neat feature. Don't mind using tmuxinator close window/pane/session vs tmux kill-pane/window/session.

I'd love to also see a general post config like the pre configuration as well. I just set up a tmuxinator session that sets up a bunch of sshfs mount points in pre and I'd love to execute a command when the tmuxinator session is done (i.e. pkill sshfs).

@ramonjavaier
Copy link

Isn't this similar to Issue #87?

@ghost
Copy link

ghost commented Sep 24, 2013

@ramonjavaier yes it is.

@ganeshran
Copy link

This feature would be really helpful. I run a rails server in one of the panes and if it doesnt get shut down properly, the next time I have to manually kill the rails process and delete the pid file

@hiromitz
Copy link

+1

@moltar
Copy link

moltar commented Jan 12, 2014

+1 # This feature would be extra sweet. Subbing for winning.

@schickling
Copy link

👍

5 similar comments
@araslanov-e
Copy link

+1

@mMontu
Copy link

mMontu commented Sep 11, 2014

+1

@carlotrimarchi
Copy link

+1

@jlipps
Copy link
Contributor

jlipps commented Dec 15, 2014

👍

@LukaK
Copy link

LukaK commented Dec 20, 2014

+1

@jlipps
Copy link
Contributor

jlipps commented Dec 21, 2014

After thinking about this, I decided that tmuxinator was the wrong place for this feature to live. So I implemented it as a tmux plugin. Please check it out and let me know what you think. https://github.com/jlipps/tmux-safekill

@ghost
Copy link

ghost commented Jun 6, 2015

Closing in favour of jlipps/tmux-safekill.

@ghost ghost closed this as completed Jun 6, 2015
@ccmcbeck
Copy link

ccmcbeck commented Oct 5, 2016

If you get here because tmux is not reliably killing rails server, you should know that it does reliably kill heroku local. Sometimes, I use rails server to run byebug, but now I always try to use heroku local in a tmux YML file.

@unlessbamboo
Copy link

+1, tmux-safekill

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests