mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
feat: support arbitrary shell
This commit is contained in:
parent
6ebd624b28
commit
5c8fa52a32
1 changed files with 12 additions and 13 deletions
25
src/shell.rs
25
src/shell.rs
|
|
@ -61,19 +61,16 @@ pub fn last_command(shell: &str) -> String {
|
|||
"zsh" => last_command,
|
||||
"fish" => last_command,
|
||||
"nu" => last_command,
|
||||
_ => {
|
||||
eprintln!("Unsupported shell: {}", shell);
|
||||
exit(1);
|
||||
}
|
||||
_ => last_command,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expand_alias(shell: &str, full_command: &str) -> String {
|
||||
let alias = std::env::var("_PR_ALIAS").expect(&t!(
|
||||
"no-env-setup",
|
||||
var = "_PR_ALIAS",
|
||||
help = "pay-respects -h"
|
||||
));
|
||||
let alias_env = std::env::var("_PR_ALIAS");
|
||||
if alias_env.is_err() {
|
||||
return full_command.to_string();
|
||||
}
|
||||
let alias = alias_env.unwrap();
|
||||
if alias.is_empty() {
|
||||
return full_command.to_string();
|
||||
}
|
||||
|
|
@ -184,11 +181,13 @@ pub fn initialization(shell: &str, binary_path: &str, auto_alias: &str) {
|
|||
};
|
||||
|
||||
let init = format!(
|
||||
r#"def --env {} [] {{
|
||||
let dir = (with-env {{ _PR_LAST_COMMAND: {}, _PR_ALIAS: {}, _PR_SHELL: nu }} {{ {} }})
|
||||
r#"
|
||||
def --env {} [] {{
|
||||
let dir = (with-env {{ _PR_LAST_COMMAND: {}, _PR_SHELL: nu }} {{ {} }})
|
||||
cd $dir
|
||||
}}"#,
|
||||
pr_alias, last_command, alias, binary_path
|
||||
}}
|
||||
"#,
|
||||
pr_alias, last_command, binary_path
|
||||
);
|
||||
println!("{}", init);
|
||||
std::process::exit(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue