micro-editor / micro-editor/micro
Allowing setting environment variables for JobSpawn/JobStart
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
Description of the problem or steps to reproduce
First of all, really awesome project! I've recently converted from emacs to using micro for a majority of my coding tasks.
One thing I need in my daily flow, is to execute all sorts of CLI programs, then observe the generated output from an editor. For example, I typically use ag/ripgrep to grep through source files.
With the powerful plugin design of micro, I can build a plugin for handling this(together with other behaviors for my need). With this plugin I can just do:
> e rg -n FooBar
Which will do a grep on source files using FooBar as a search term, then gather all results in a split.
Tho there is one thing bothering me: right now JobSpawn/JobStart in micro only executes the command in the directory where micro is started within. If I wand to do a grep on a specific folder, I will have to do the following:
> e rg -n FooBar path/to/folder
One thing acme brings, is that when executing an external program, an environment variable will be set to the full path from the file being edited. This can enable the following workflow:
- Start micro from the project root folder
/foo/baz - Edit a file in
/foo/baz/src/test.txt - I can now build a shell wrapper, when executed, will first read the file path
/foo/baz/src/test.txtfrom an environment variable, deduce the directory/foo/baz/src, then generate commands to executergfrom this folder instead of the default/foo/baz.
One thing that is blocking this workflow, is that JobSpawn/JobStart does not have a way to inject environment variables. Basically I see 2 ways of getting this done:
- Enhance the APIs so environment variables can be passed in to JobSpawn/JobStart
- Another way is to split JobSpawn/JobStart into 2 parts: first use JobCreate to create the job, allowing plugin authors to modify the Job in any way they want, then a second API allows starting the job. This not only allows customizing environment variable, but would also allow customizing other parts
Cmdin golang allows, such as changing working directory directly.
That comes to my real question: are you open to making either of the above 2 adjustments, so environment variables or working directory can be set for external programs launched via JobSpawn/JobStart?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the JobSpawn and JobStart plugin APIs, then compare them with JobCreate and the customization available on Go's Cmd. Decide how environment variables or a working directory should be supplied, and verify that a plugin can launch an external command relative to the file being edited.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100