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 4828b03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 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
1 change: 0 additions & 1 deletion helix-term/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::keymap::Keymaps;
#[derive(Debug, Default, Clone, PartialEq, Deserialize)]
pub struct Config {
pub theme: Option<String>,
pub shell: Option<Vec<String>>,
#[serde(default)]
pub lsp: LspConfig,
#[serde(default)]
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 4828b03

Please sign in to comment.