From 8c4f9308c656c56bfb2744696c34843ed2542e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Donk=C3=B3?= Date: Mon, 15 Jan 2024 11:18:52 +0100 Subject: [PATCH] feat: add `YAZI_LEVEL` env variable for shells --- yazi-plugin/src/external/shell.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yazi-plugin/src/external/shell.rs b/yazi-plugin/src/external/shell.rs index c93115a1..ea4d3071 100644 --- a/yazi-plugin/src/external/shell.rs +++ b/yazi-plugin/src/external/shell.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsString, process::Stdio}; +use std::{env, ffi::OsString, process::Stdio}; use anyhow::Result; use tokio::process::{Child, Command}; @@ -32,6 +32,15 @@ pub fn shell(opt: ShellOpt) -> Result { #[cfg(unix)] return Ok(unsafe { Command::new("sh") + .env( + "YAZI_LEVEL", + (env::var("YAZI_LEVEL") + .ok() + .and_then(|lvl_str| lvl_str.parse::().ok()) + .unwrap_or(0) + + 1) + .to_string(), + ) .arg("-c") .stdin(opt.stdio()) .stdout(opt.stdio())