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

feature request: strategy of using tmux to run task #350

Open
1 task done
patricorgi opened this issue Sep 7, 2024 · 2 comments
Open
1 task done

feature request: strategy of using tmux to run task #350

patricorgi opened this issue Sep 7, 2024 · 2 comments
Labels
enhancement New feature or request P2 Not a priority. PRs welcome

Comments

@patricorgi
Copy link

patricorgi commented Sep 7, 2024

Did you check existing requests?

  • I have searched the existing issues
    • There was an issue related to tmux pane. It was closed because it's not straightforward to get output from the job running in the separate tmux pane. However, I'm more looking towards a tmux strategy to launch the task in tmux using the powerful task definition panel of overseer, and there's no need to deal with the output of the task.

Describe the feature

offer a strategy to run tasks in a separate tmux pane or tmux window

Provide background

I found overseer extremely useful in quickly launching predefined tasks. After using overseer for a few months, I think it's the best neovim task manager / code runner (whatever you wanna call it), and I have defined many useful templates. It's become a crucial part of my workflow.

However, some tasks can take hours/days. Naturally I run these tasks inside tmux all the time. These tasks use the context of my neovim activities, but once launched they usually don't have a strong bond to my other neovim activities any more. Therefore, it will be extremely useful for me if I can "detach" these tasks from neovim and run them in a separate tmux pane or tmux window.

There's already a plugin called otavioschwanck/tmux-awesome-manager.nvim which can do this type of thing. But as I said overseer is not only powerful but very flexible in grabbing neovim context, and put it into the task definition. It will be great if overseer can achieve the same thing or integrate otavioschwanck/tmux-awesome-manager.nvim.

What is the significance of this feature?

strongly desired

Additional details

No response

@patricorgi patricorgi added the enhancement New feature or request label Sep 7, 2024
@stevearc
Copy link
Owner

The main barrier is that AFAIK there isn't a way to run a command in tmux and stream the output back to Neovim. Many of the features and components in overseer require that output, so a naive tmux strategy would cause a bunch of functionality to just break. If you or someone else knows of a way to make that work, I would review a PR.

@stevearc stevearc added the P2 Not a priority. PRs welcome label Sep 11, 2024
@serranomorante
Copy link

I found a nasty workaround: Using tmux directly in the cmd and args properties of your task.

I'm currently testing something like this:

definition for typescript watch task

    name = "tsc-watch-overseer-task-name", -- will also be used as the tmux session name
    return {
      cmd = { "tmux" },
      args = { "new-session", "-A", "-s", "tsc-watch-overseer-task-name", "tsc", "--watch", "--pretty", "false" }, -- --pretty=false to exclude a lot of ANSI escape codes

This creates (and attach to) a new tmux session that executes the tsc --watch --pretty false command.

From my tests, overseer keeps reading the terminal buffer output normally so the majority of functionality and problem matchers keep working. Although, you will still face some issues with ANSI escape codes.

For example, I had to do a quick modification to this overseer function here. We could definitely improve this implementation.

M.remove_ansi = function(str)
  local ret = str
    :gsub("[\27\155][][()#;?%d]*[A-PRZcf-ntqry=><~]", "") -- <-- my change
    :gsub("\x1b%[[%d;]*m", "")
    :gsub("\x1b%[%d*K", "")
    :gsub("\x1b%[3d", "") -- <-- my change

The main benefit I inmediatelly noticed from this is:

  • Closing nvim will not kill long lived tasks. Entering nvim again and running the same task will start inmediatelly exactly where it was, without having to re-run the process from scratch.
tmux-overseer-nvim-.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2 Not a priority. PRs welcome
Projects
None yet
Development

No branches or pull requests

3 participants