From aee599ca9a5d1623dfad282426b17072a7f02e34 Mon Sep 17 00:00:00 2001 From: Yuki Ito Date: Fri, 1 Nov 2019 23:06:43 +0900 Subject: [PATCH] Make SHLVL correction can be disabled by configuration --- README.md | 2 +- conf.d/__async_prompt.fish | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 971a60a..5bb9cf2 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ If your prompt don't work correctly, try changeing the configuration. Define variables inherited to prompt functions. Set `all` to pass all global variables. -**Default:** `status` +**Default:** `status SHLVL` ### Variable: `async_prompt_functions` diff --git a/conf.d/__async_prompt.fish b/conf.d/__async_prompt.fish index 39510aa..7b42e92 100644 --- a/conf.d/__async_prompt.fish +++ b/conf.d/__async_prompt.fish @@ -73,19 +73,24 @@ if status is-interactive end function __async_prompt_spawn + set -l envs begin set st $argv[1] while read line - contains $line FISH_VERSION PWD SHLVL _ history + contains $line FISH_VERSION PWD _ history and continue - if test "$line" = status + switch "$line" + case status echo status $st - else - or echo $line (string escape -- $$line) + case SHLVL + set envs $envs SHLVL=(math $SHLVL - 1) + case '*' + echo $line (string escape -- $$line) end end - end | env SHLVL=(math "$SHLVL-1") fish -c 'function __async_prompt_ses + end | read -lz vars + echo $vars | env $envs fish -c 'function __async_prompt_ses return $argv end while read -a line @@ -116,6 +121,7 @@ if status is-interactive end else echo status + echo SHLVL end end