mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: add YAZI_LEVEL env variable for shells (#514)
This commit is contained in:
parent
ca78f4c9b0
commit
cb80ca81da
1 changed files with 5 additions and 1 deletions
6
yazi-plugin/src/external/shell.rs
vendored
6
yazi-plugin/src/external/shell.rs
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{ffi::OsString, process::Stdio};
|
use std::{env, ffi::OsString, process::Stdio};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::process::{Child, Command};
|
use tokio::process::{Child, Command};
|
||||||
|
|
@ -29,9 +29,12 @@ impl ShellOpt {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shell(opt: ShellOpt) -> Result<Child> {
|
pub fn shell(opt: ShellOpt) -> Result<Child> {
|
||||||
|
let level = env::var("YAZI_LEVEL").ok().and_then(|s| s.parse::<u32>().ok()).unwrap_or(0);
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
return Ok(unsafe {
|
return Ok(unsafe {
|
||||||
Command::new("sh")
|
Command::new("sh")
|
||||||
|
.env("YAZI_LEVEL", (level + 1).to_string())
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.stdin(opt.stdio())
|
.stdin(opt.stdio())
|
||||||
.stdout(opt.stdio())
|
.stdout(opt.stdio())
|
||||||
|
|
@ -56,6 +59,7 @@ pub fn shell(opt: ShellOpt) -> Result<Child> {
|
||||||
let expanded = parser::parse(opt.cmd.to_string_lossy().as_ref(), &args_);
|
let expanded = parser::parse(opt.cmd.to_string_lossy().as_ref(), &args_);
|
||||||
Ok(
|
Ok(
|
||||||
Command::new("cmd")
|
Command::new("cmd")
|
||||||
|
.env("YAZI_LEVEL", (level + 1).to_string())
|
||||||
.arg("/C")
|
.arg("/C")
|
||||||
.args(&expanded)
|
.args(&expanded)
|
||||||
.stdin(opt.stdio())
|
.stdin(opt.stdio())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue