Add support for `ZK_SHELL` (#166)

pull/171/head
Mickaël Menu 2 years ago committed by GitHub
parent c6e529fdfa
commit e037befdf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
* [#144](https://github.com/mickael-menu/zk/issues/144) LSP auto-completion of YAML frontmatter tags.
* [zk-nvim#26](https://github.com/mickael-menu/zk-nvim/issues/26) The LSP server doesn't use `additionalTextEdits` anymore to remove the trigger characters when completing links.
* You can customize the default behavior with the [`use-additional-text-edits` configuration key](docs/config-lsp.md).
* [#163](https://github.com/mickael-menu/zk/issues/163) Use the `ZK_SHELL` environment variable to override the shell for `zk` only.
### Fixed

@ -3,16 +3,18 @@
package exec
import (
"os"
"os/exec"
osutil "github.com/mickael-menu/zk/internal/util/os"
)
// CommandFromString returns a Cmd running the given command with $SHELL.
func CommandFromString(command string, args ...string) *exec.Cmd {
shell := os.Getenv("SHELL")
if len(shell) == 0 {
shell = "sh"
}
shell := osutil.GetOptEnv("ZK_SHELL").
Or(osutil.GetOptEnv("SHELL")).
OrString("sh").
Unwrap()
args = append([]string{"-c", command, "--"}, args...)
return exec.Command(shell, args...)
}

Loading…
Cancel
Save