forked from mirrors/jj
commands: respect $EDITOR from environment
Until recently, we didn't have support for `.gitignore` files. That meant that editors (like Emacs) that leave backup files around were annoying to use, because you'd have to manually remove the backup file afterwards. For that reason, I had hard-coded the editor to be `pico`. Now we have support for `.gitignore` files, so we can start respecting the user's $EDITOR.
This commit is contained in:
parent
d7b9bd55e8
commit
ba4d2c8a24
1 changed files with 6 additions and 1 deletions
|
@ -1139,7 +1139,12 @@ fn edit_description(repo: &ReadonlyRepo, description: &str) -> String {
|
|||
description_file.write_all(description.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
let exit_status = Command::new("pico")
|
||||
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "pico".to_string());
|
||||
// Handle things like `EDITOR=emacs -nw`
|
||||
let args: Vec<_> = editor.split(' ').collect();
|
||||
let editor_args = if args.len() > 1 { &args[1..] } else { &[] };
|
||||
let exit_status = Command::new(args[0])
|
||||
.args(editor_args)
|
||||
.arg(&description_file_path)
|
||||
.status()
|
||||
.expect("failed to run editor");
|
||||
|
|
Loading…
Reference in a new issue