Fix behavior in fish

Fixes #419
This commit is contained in:
Denis Isidoro 2021-04-15 18:52:01 -03:00 committed by GitHub
parent 42ef14c06a
commit 06d728c377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View file

@ -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()
)),

View file

@ -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,

View file

@ -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)]