Fix #4 terminal borked when piping content with Vim

This commit is contained in:
Mickaël Menu 2021-03-20 16:31:11 +01:00
parent c58e68e0e2
commit ec574ff519
No known key found for this signature in database
GPG Key ID: 53D73664CD359895
2 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,10 @@ All notable changes to this project will be documented in this file.
* By setting `ZK_NOTEBOOK_DIR` in your shell configuration file (e.g. `~/.profile`), you are declaring a default global notebook which will be used when `zk` is not in a notebook.
* When the notebook directory is set explicitly, any path given as argument will be relative to it instead of the actual working directory.
### Fixed
* [#4](https://github.com/mickael-menu/zk/issues/4) Terminal borked when piping content with Vim
## 0.2.1

View File

@ -20,7 +20,11 @@ func Edit(zk *zk.Zk, paths ...string) error {
return fmt.Errorf("no editor set in config")
}
cmd := executil.CommandFromString(editor.String() + " " + shellquote.Join(paths...))
// /dev/tty is restored as stdin, in case the user used a pipe to feed
// initial note content to `zk new`. Without this, Vim doesn't work
// properly in this case.
// See https://github.com/mickael-menu/zk/issues/4
cmd := executil.CommandFromString(editor.String() + " " + shellquote.Join(paths...) + " </dev/tty")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr