Added modiciation from a parallel project
This commit is contained in:
parent
e14d5f3566
commit
278be5a6c6
24 changed files with 492 additions and 143 deletions
23
_home/dot_sz.shrc.d/02_shlvl
Normal file
23
_home/dot_sz.shrc.d/02_shlvl
Normal file
|
@ -0,0 +1,23 @@
|
|||
function shlvl() {
|
||||
local SHLVL_VAR="SHLVL_${SFP##*.}"
|
||||
local SHELLS=$( \
|
||||
cat /etc/shells \
|
||||
| tail +2 \
|
||||
| sed 's/.*\///' \
|
||||
| sort -u \
|
||||
| grep -v tmux \
|
||||
| paste -sd '|' \
|
||||
)
|
||||
local SHLVL_VAL=$(eval "printf '%s' \"\$$SHLVL_VAR\"")
|
||||
if [[ -z "$SHLVL_VAL" ]]; then
|
||||
SHLVL_VAL=$(( $( \
|
||||
pstree -s $$ \
|
||||
| head -1 \
|
||||
| sed -r 's/-\+-/---/g; s/-[^-]+---oh-my-posh---.*/-/; s/---/\n/g;' \
|
||||
| grep -Ec "^($SHELLS)$"
|
||||
) - ${1:-1} ))
|
||||
eval "export $SHLVL_VAR=$SHLVL_VAL"
|
||||
fi
|
||||
echo $SHLVL_VAL
|
||||
}
|
||||
shlvl > /dev/null
|
Loading…
Add table
Add a link
Reference in a new issue