Add shell configuration to Shell plugin

This commit is contained in:
Kirottu
2023-01-01 11:28:36 +02:00
parent 885601cde0
commit 9f12e3e192

View File

@@ -7,12 +7,14 @@ use serde::Deserialize;
#[derive(Deserialize)] #[derive(Deserialize)]
struct Config { struct Config {
prefix: String, prefix: String,
shell: Option<String>,
} }
impl Default for Config { impl Default for Config {
fn default() -> Self { fn default() -> Self {
Config { Config {
prefix: ":sh".to_string(), prefix: ":sh".to_string(),
shell: None,
} }
} }
} }
@@ -39,8 +41,14 @@ fn get_matches(input: RString, config: &mut Config) -> RVec<Match> {
vec![Match { vec![Match {
title: command.into(), title: command.into(),
description: ROption::RSome( description: ROption::RSome(
env::var("SHELL") config
.unwrap_or_else(|_| "No shell!".to_string()) .shell
.clone()
.unwrap_or_else(|| {
env::var("SHELL").unwrap_or_else(|_| {
"The shell could not be determined!".to_string()
})
})
.into(), .into(),
), ),
icon: ROption::RNone, icon: ROption::RNone,