GithubHelp home page GithubHelp logo

Comments (26)

xntrik avatar xntrik commented on June 24, 2024 1

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

from tmuxinator.

unlessbamboo avatar unlessbamboo commented on June 24, 2024 1

+1, tmux-safekill

from tmuxinator.

klaut avatar klaut commented on June 24, 2024

+1

from tmuxinator.

philipsahli avatar philipsahli commented on June 24, 2024

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

from tmuxinator.

sebastibe avatar sebastibe commented on June 24, 2024

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

from tmuxinator.

 avatar commented on June 24, 2024

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.

from tmuxinator.

xntrik avatar xntrik commented on June 24, 2024

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

from tmuxinator.

 avatar commented on June 24, 2024

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?

from tmuxinator.

xntrik avatar xntrik commented on June 24, 2024

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.

from tmuxinator.

chibicode avatar chibicode commented on June 24, 2024

@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.

from tmuxinator.

 avatar commented on June 24, 2024

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

from tmuxinator.

amaltson avatar amaltson commented on June 24, 2024

👍 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).

from tmuxinator.

ramonjavaier avatar ramonjavaier commented on June 24, 2024

Isn't this similar to Issue #87?

from tmuxinator.

 avatar commented on June 24, 2024

@ramonjavaier yes it is.

from tmuxinator.

ganeshran avatar ganeshran commented on June 24, 2024

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

from tmuxinator.

hiromitz avatar hiromitz commented on June 24, 2024

+1

from tmuxinator.

moltar avatar moltar commented on June 24, 2024

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

from tmuxinator.

schickling avatar schickling commented on June 24, 2024

👍

from tmuxinator.

araslanov-e avatar araslanov-e commented on June 24, 2024

+1

from tmuxinator.

mMontu avatar mMontu commented on June 24, 2024

+1

from tmuxinator.

carlotrimarchi avatar carlotrimarchi commented on June 24, 2024

+1

from tmuxinator.

jlipps avatar jlipps commented on June 24, 2024

👍

from tmuxinator.

LukaK avatar LukaK commented on June 24, 2024

+1

from tmuxinator.

jlipps avatar jlipps commented on June 24, 2024

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

from tmuxinator.

 avatar commented on June 24, 2024

Closing in favour of jlipps/tmux-safekill.

from tmuxinator.

ccmcbeck avatar ccmcbeck commented on June 24, 2024

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.

from tmuxinator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.