Skip to content

Commit

Permalink
Move shell config to editor and use in command
Browse files Browse the repository at this point in the history
  • Loading branch information
Omnikar committed Aug 9, 2021
1 parent 689b2b5 commit e293d24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 4 additions & 11 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4087,17 +4087,10 @@ fn shell_filter(cx: &mut Context) {
fn shell(cx: &mut Context, prompt: &str, pipe: bool, behavior: ShellBehavior) {
use std::io::Write;
use std::process::{Command, Stdio};
let shell = Option::<Vec<_>>::None; // this should come from config, but can't currently
let shell = match shell {
Some(v) if !v.is_empty() => v,
_ => {
if cfg!(windows) {
vec!["cmd".to_owned(), "/C".to_owned()]
} else {
vec!["sh".to_owned(), "-c".to_owned()]
}
}
};
let shell = cx.editor.config.shell.clone();
if shell.is_empty() {
return;
}
let prompt = Prompt::new(
prompt.to_owned(),
Some('|'),
Expand Down
7 changes: 7 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ pub struct Config {
pub scrolloff: usize,
/// Mouse support. Defaults to true.
pub mouse: bool,
/// Shell to use for shell commands. Defaults to ["cmd", "/C"] on Windows and ["sh", "-c"] otherwise.
pub shell: Vec<String>,
}

impl Default for Config {
fn default() -> Self {
Self {
scrolloff: 5,
mouse: true,
shell: if cfg!(windows) {
vec!["cmd".to_owned(), "/C".to_owned()]
} else {
vec!["sh".to_owned(), "-c".to_owned()]
},
}
}
}
Expand Down

0 comments on commit e293d24

Please sign in to comment.