mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
feat: better generic shell handling
This commit is contained in:
parent
41d6b04ea5
commit
3a2ac2fa63
3 changed files with 14 additions and 8 deletions
|
|
@ -86,6 +86,12 @@ Please follow the instruction for your shell:
|
||||||
> eval $(_PR_SHELL=sh _PR_LAST_COMMAND="git comit" pay-respects)
|
> eval $(_PR_SHELL=sh _PR_LAST_COMMAND="git comit" pay-respects)
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
|
> Following variables are not required, but can be used to reduce unnecessary operations:
|
||||||
|
>
|
||||||
|
> - `_PR_ALIAS`: A list of aliases to commands. Separated by newlines with zsh-like formatting, e.g. `gc=git commit`
|
||||||
|
> - `_PR_ERROR_MSG`: Error message from the previous command. `pay-respects` will rerun previous command to get the error message if absent
|
||||||
|
> - `_PR_EXECUTABLES`: A space separated list of commands/executables. `pay-respects` will search for `$PATH` if absent
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
let shell = std::env::var("_PR_SHELL").expect("_PR_SHELL not set");
|
let shell = std::env::var("_PR_SHELL").expect("_PR_SHELL not set");
|
||||||
let last_command = std::env::var("_PR_LAST_COMMAND").expect("_PR_LAST_COMMAND not set");
|
let last_command = std::env::var("_PR_LAST_COMMAND").expect("_PR_LAST_COMMAND not set");
|
||||||
let error_msg = std::env::var("_PR_ERROR_MSG").expect("_PR_ERROR_MSG not set");
|
let error_msg = std::env::var("_PR_ERROR_MSG").expect("_PR_ERROR_MSG not set");
|
||||||
let executables: Vec<String> = {
|
let executables: Vec<String> = get_path_files();
|
||||||
let exes = std::env::var("_PR_EXECUTABLES").expect("_PR_EXECUTABLES not set");
|
|
||||||
if exes.is_empty() {
|
|
||||||
get_path_files()
|
|
||||||
} else {
|
|
||||||
exes.split(" ").map(|s| s.to_string()).collect()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ use crate::evals::find_similar;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
pub fn get_path_files() -> Vec<String> {
|
pub fn get_path_files() -> Vec<String> {
|
||||||
|
let env = std::env::var("_PR_EXECUTABLES");
|
||||||
|
if let Ok(env) = env {
|
||||||
|
if !env.is_empty() {
|
||||||
|
return env.split(' ').map(|s| s.to_owned()).collect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let path_env = path_env();
|
let path_env = path_env();
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue