Add SHLVL item (#165)

* Add SHLVL item

* Run function in subshell

* Python bug?

* Revert "Python bug?"

This reverts commit 79fbadc29f.

* Change icon

* Fix macOS test

* Run on Linux only
This commit is contained in:
Kid 2021-06-24 05:47:28 +08:00 committed by GitHub
parent c9e4c0c14a
commit b8f832c09d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,5 @@
function _tide_item_shlvl
# Item functions run in a deeper level of shell
set -l real_shlvl (math $SHLVL - 1)
test $real_shlvl -gt $tide_shlvl_threshold && _tide_print_item shlvl $tide_shlvl_icon' ' $real_shlvl
end

View File

@ -69,6 +69,10 @@ tide_right_prompt_suffix ''
tide_rustc_bg_color 444444
tide_rustc_color 00AFAF
tide_rustc_icon ''
tide_shlvl_bg_color 444444
tide_shlvl_color d78700
tide_shlvl_icon ''
tide_shlvl_threshold 1
tide_status_bg_color_failure 444444
tide_status_bg_color_success 444444
tide_status_color_failure D70000

View File

@ -34,6 +34,8 @@ tide_pwd_color_dirs cyan
tide_pwd_color_truncated_dirs magenta
tide_rustc_bg_color black
tide_rustc_color cyan
tide_shlvl_bg_color black
tide_shlvl_color yellow
tide_status_bg_color_failure black
tide_status_bg_color_success black
tide_status_color_failure red

View File

@ -69,6 +69,10 @@ tide_right_prompt_suffix ''
tide_rustc_bg_color normal
tide_rustc_color 00AFAF
tide_rustc_icon ''
tide_shlvl_bg_color normal
tide_shlvl_color d78700
tide_shlvl_icon ''
tide_shlvl_threshold 1
tide_status_bg_color_failure normal
tide_status_bg_color_success normal
tide_status_color_failure D70000

View File

@ -34,6 +34,8 @@ tide_pwd_color_dirs cyan
tide_pwd_color_truncated_dirs magenta
tide_rustc_bg_color normal
tide_rustc_color cyan
tide_shlvl_bg_color normal
tide_shlvl_color yellow
tide_status_bg_color_failure normal
tide_status_bg_color_success normal
tide_status_color_failure red

View File

@ -69,6 +69,10 @@ tide_right_prompt_suffix ''
tide_rustc_bg_color FF8700
tide_rustc_color 2E3436
tide_rustc_icon ''
tide_shlvl_bg_color 808000
tide_shlvl_color 000000
tide_shlvl_icon ''
tide_shlvl_threshold 1
tide_status_bg_color_failure CC0000
tide_status_bg_color_success 2E3436
tide_status_color_failure FFFF00

View File

@ -34,6 +34,8 @@ tide_pwd_color_dirs brwhite
tide_pwd_color_truncated_dirs white
tide_rustc_bg_color yellow
tide_rustc_color black
tide_shlvl_bg_color yellow
tide_shlvl_color black
tide_status_bg_color_failure red
tide_status_bg_color_success black
tide_status_color_failure bryellow

View File

@ -0,0 +1,12 @@
# RUN: %fish %s
# REQUIRES: test $(uname) = Linux
function _shlvl
_tide_decolor (fish -c _tide_item_shlvl)
end
_shlvl # CHECK:  2
set -lx tide_shlvl_threshold 2
_shlvl # CHECK: