Skip to content

dynamic reload? #3736

Closed
Closed

Description

@Dreuzz

is there a way for micro to reload dynamically or reload it via the terminal while a session is open?

I want to use matugen to dynamically change the theme but micro doesnt reload dynamically and I have to use the reload command :/

Kooha-2025-05-05-22-09-21.mp4

Activity

  1. dmaluka commented on May 5, 2025

    @dmaluka
    Collaborator

    This essentially boils down to a question how to send a command to micro remotely, via a socket or something. I don't think there is such a possibility, unfortunately.

  2. cutelisp commented on May 8, 2025

    @cutelisp
    Contributor

    My knowledge of Micro is about the same as my knowledge of ricing—almost zero. Still, I had an idea you could use as a last resort.

    If there's no direct way to send a command to Micro, as a final option, you might be able to make Micro reload itself—maybe through an infinite reload loop or by using a file as a socket.

    I’m not sure how to implement this properly, but I had an idea. Once this #3733. gets merged , you could create an overlay that reloads the config continuously or read the content of a file and reload with some condition. It’s definitely not a clean solution, but I tested it and it seems to work.

  3. JoeKar commented on May 8, 2025

    @JoeKar
    Member

    At least with a Lua plugin someone could implement the necessary interface and access whatever micro exports. It is limited what micro exports, but it is much more than nothing.

  4. dmaluka commented on May 8, 2025

    @dmaluka
    Collaborator

    Once this #3733. gets merged , you could create an overlay that reloads the config continuously or read the content of a file and reload with some condition.

    You mean, a plugin continuously calling ReloadCmd() in a busy loop? I'm not sure what overlays have to do with that, but anyway that would be a really bad idea (I hope I don't need to explain why).

    Or you could do that at regular time intervals (I think you can already do that, using a timer, with After()), that would be not as bad, but still feels quite silly.

    A better approach would be to use something like https://pkg.go.dev/github.com/fsnotify/fsnotify...

  5. cutelisp commented on May 9, 2025

    @cutelisp
    Contributor

    You mean, a plugin continuously calling ReloadCmd() in a busy loop? I'm not sure what overlays have to do with that, but anyway that would be a really bad idea (I hope I don't need to explain why).

    kinda, callingconfig.Reload()(maybe not in every iteration)
    I've mention overlays, because I think a plugin with a busy loop would freeze micro, right?

    Or you could do that at regular time intervals (I think you can already do that, using a timer, with After()), that would be not as bad, but still feels quite silly.

    Could you provide a short snippet or describe a bit more that approach by any chance?
    It might be silly but I got curious 😆

  6. dmaluka commented on May 9, 2025

    @dmaluka
    Collaborator

    Could you provide a short snippet or describe a bit more that approach by any chance?

    local time = import("time")
    local interval = time.ParseDuration("1s")
    
    local function periodicReload()
        config.Reload()
        micro.After(interval, periodicReload)
    end
    
    function init()
        micro.After(interval, periodicReload)
    end

    BTW please ignore my above suggestion to use ReloadCmd(), it does exactly what the reload command does, so it would not just reload config files but also reinitialize all plugins, including your plugin which calls it, which is probably a bad idea, so you should use config.Reload() which just reloads config files (and it exists specifically for use by plugins).

  7. cutelisp commented on May 9, 2025

    @cutelisp
    Contributor

    BTW please ignore my above suggestion to use ReloadCmd(), it does exactly what the reload command does, so it would not just reload config files but also reinitialize all plugins, including your plugin which calls it, which is probably a bad idea, so you should use config.Reload() which just reloads config files (and it exists specifically for use by plugins).

    Ty, that's definitely a better approach, although I've noticed whenconfig.Reload() is called my other plugins don't really work.

  8. dmaluka commented on May 9, 2025

    @dmaluka
    Collaborator

    whenconfig.Reload() is called my other plugins don't really work.

    Sounds like a bug.

  9. SLUCHABLUB commented on Aug 18, 2025

    @SLUCHABLUB

    You could define SIGUSR1 to reload the config. That is what kitty does. I don't know however if the signals are taken yet however.

  10. locked and limited conversation to collaborators on Aug 26, 2026
  11. converted this issue into a discussion #4197 on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions