summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2021-04-15 18:52:01 -0300
committerGitHub <noreply@github.com>2021-04-15 18:52:01 -0300
commit06d728c377f090e4b89d2314629414ab7a03d6d4 (patch)
tree4cdd4293f8e85559b576bfa4505945052bb0bf47
parent42ef14c06afbeaf4ca8b25e9b31710105c01f544 (diff)
Fix behavior in fish
Fixes #419
-rw-r--r--src/actor.rs8
-rw-r--r--src/finder/mod.rs7
-rw-r--r--src/shell.rs2
3 files changed, 10 insertions, 7 deletions
diff --git a/src/actor.rs b/src/actor.rs
index 5efe8bc..4a9a917 100644
--- a/src/actor.rs
+++ b/src/actor.rs
@@ -4,7 +4,7 @@ use crate::extractor;
use crate::finder::structures::{Opts as FinderOpts, SuggestionType};
use crate::finder::Finder;
use crate::shell;
-use crate::shell::{ShellSpawnError, IS_FISH};
+use crate::shell::ShellSpawnError;
use crate::structures::cheat::{Suggestion, VariableMap};
use crate::structures::config::Action;
use crate::structures::config::Config;
@@ -78,15 +78,13 @@ fn prompt_finder(
let mut opts = FinderOpts {
overrides,
preview: Some(format!(
- r#"{prefix}navi preview-var "$(cat <<NAVIEOF
+ r#"navi preview-var "$(cat <<NAVIEOF
{{+}}
NAVIEOF
)" "$(cat <<NAVIEOF
{{q}}
NAVIEOF
-)" "{name}"; {extra}{suffix}"#,
- prefix = if *IS_FISH { "bash -c '" } else { "" },
- suffix = if *IS_FISH { "'" } else { "" },
+)" "{name}"; {extra}"#,
name = variable_name,
extra = extra_preview.clone().unwrap_or_default()
)),
diff --git a/src/finder/mod.rs b/src/finder/mod.rs
index 0bb1ed1..e17f5c6 100644
--- a/src/finder/mod.rs
+++ b/src/finder/mod.rs
@@ -1,3 +1,4 @@
+use crate::shell;
use crate::structures::cheat::VariableMap;
use crate::writer;
use anyhow::Context;
@@ -144,7 +145,11 @@ impl Finder for FinderChoice {
});
}
- let child = command.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn();
+ let child = command
+ .env("SHELL", &*shell::SHELL)
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .spawn();
let mut child = match child {
Ok(x) => x,
diff --git a/src/shell.rs b/src/shell.rs
index 2eff18f..1870e5b 100644
--- a/src/shell.rs
+++ b/src/shell.rs
@@ -7,7 +7,7 @@ lazy_static! {
pub static ref IS_FISH: bool = env_var::get("SHELL")
.unwrap_or_else(|_| "".to_string())
.contains(&"fish");
- static ref SHELL: String = env_var::get(env_var::SHELL).unwrap_or_else(|_| "bash".to_string());
+ pub static ref SHELL: String = env_var::get(env_var::SHELL).unwrap_or_else(|_| "bash".to_string());
}
#[derive(Debug)]