Coder Social home page Coder Social logo

Feature: smug stop within session about smug HOT 12 CLOSED

ivaaaan avatar ivaaaan commented on May 26, 2024 1
Feature: smug stop within session

from smug.

Comments (12)

ivaaaan avatar ivaaaan commented on May 26, 2024

Hey. Thanks for the suggestion. What do you mean by an expected session name?
Am I correct, that you want to allow smug stop, which will terminate the current tmux session?

from smug.

benyanke avatar benyanke commented on May 26, 2024

Yes, exactly. Stop without arguments would kill the current session, along with any stop hooks defined.

You'd have to loop over the files in the config and find if any have the tmux session name matching the one you're in, based on my cursory investigation, since the name of the smug config file doesn't always match the tmux session it creates.

from smug.

ivaaaan avatar ivaaaan commented on May 26, 2024

Looping file content doesn't sound like a great idea, probably will be very slow if you have many files. I'll think about what's the best here.

from smug.

benyanke avatar benyanke commented on May 26, 2024

It's the only way I've been able to consider doing it so far, given that there's no way to look up a file by it's tmux session name, a field in the file.

from smug.

benyanke avatar benyanke commented on May 26, 2024

I have a PR half done, I can push it for you to check out if you're curious

from smug.

ivaaaan avatar ivaaaan commented on May 26, 2024

I've added this feature. However, it will only work if the session name is the same as the project name. Maybe I will change it when I have a better solution than iterating all files.

from smug.

benyanke avatar benyanke commented on May 26, 2024

Thanks!

Would you be open to a solution that iterates the files, but only after not finding one by project name?

I make heavy use of longer tmux session names, and short project names, and really there's no way to do it without either iterating them, or building some sort of out of band index.

However, it seems it could be acceptable if you know you're using the slower method, as the slower method would still be faster than having to type out the entire thing, and after failing to succeed in the faster method.

Thoughts?

from smug.

ivaaaan avatar ivaaaan commented on May 26, 2024

I don't mind that it's slow, but I also don't want to add a lot of new functionality right now, because I'm planning a refactoring. I'll keep it open and think about this.

from smug.

benyanke avatar benyanke commented on May 26, 2024

I have an idea!

Would it be possible to add $SMUG_SESSION_NAME, $SMUG_SESSION_CONFIG_PATH or something similar into all smug sessions when they start? That way, if you're running smug from within a tmux session, it can be aware of what config file generated the session, without needing to reverse engineer the config file from just the tmux session name, which as discussed would involve iterating over files.

I could try and throw a PR your way if you're interested in something along these lines.

Thoughts?

from smug.

ivaaaan avatar ivaaaan commented on May 26, 2024

Very good idea. Feel free to create a PR.

from smug.

benyanke avatar benyanke commented on May 26, 2024

Ok, check out PR #92 - I added an initial implementation that has been working for me.

from smug.

ivaaaan avatar ivaaaan commented on May 26, 2024

Thanks, @benyanke! I have adapted it and merged #95

from smug.

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.