Skip to content

Commit cb80ca8

Browse files
authored
feat: add YAZI_LEVEL env variable for shells (#514)
1 parent ca78f4c commit cb80ca8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

yazi-plugin/src/external/shell.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{ffi::OsString, process::Stdio};
1+
use std::{env, ffi::OsString, process::Stdio};
22

33
use anyhow::Result;
44
use tokio::process::{Child, Command};
@@ -29,9 +29,12 @@ impl ShellOpt {
2929
}
3030

3131
pub fn shell(opt: ShellOpt) -> Result<Child> {
32+
let level = env::var("YAZI_LEVEL").ok().and_then(|s| s.parse::<u32>().ok()).unwrap_or(0);
33+
3234
#[cfg(unix)]
3335
return Ok(unsafe {
3436
Command::new("sh")
37+
.env("YAZI_LEVEL", (level + 1).to_string())
3538
.arg("-c")
3639
.stdin(opt.stdio())
3740
.stdout(opt.stdio())
@@ -56,6 +59,7 @@ pub fn shell(opt: ShellOpt) -> Result<Child> {
5659
let expanded = parser::parse(opt.cmd.to_string_lossy().as_ref(), &args_);
5760
Ok(
5861
Command::new("cmd")
62+
.env("YAZI_LEVEL", (level + 1).to_string())
5963
.arg("/C")
6064
.args(&expanded)
6165
.stdin(opt.stdio())

0 commit comments

Comments
 (0)