🐛 Fix the spinner shown during execute
This commit is contained in:
parent
6429e703fd
commit
7e9914efce
1 changed files with 12 additions and 10 deletions
|
@ -72,21 +72,23 @@ end
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
function show_spinner -a pid cmds msg
|
function show_spinner -a pid cmds msg
|
||||||
set -l frames '/-\|'
|
set -f frames '/-\|'
|
||||||
|
|
||||||
set -l number_of_frames (string length $FRAMES)
|
set -f number_of_frames (string length $frames)
|
||||||
|
|
||||||
set -l i 0
|
set -f i 0
|
||||||
set -l frame_text ""
|
set -f frame_text ""
|
||||||
|
|
||||||
printf "\n\n\n"
|
printf "\n\n\n"
|
||||||
tput cuu 3
|
tput cuu 3
|
||||||
tput sc
|
tput sc
|
||||||
|
|
||||||
while kill -0 "$pid" &>/dev/null
|
while kill -0 "$pid" &>/dev/null
|
||||||
set i math $i + 1
|
set i (math "$i + 1")
|
||||||
set -l num math % $number_of_frames
|
set -l num (math "($i % $number_of_frames) + 1")
|
||||||
set -l frame (string sub -s $num -l 1)
|
|
||||||
|
set -l frame (string sub -s $num -l 1 $frames)
|
||||||
|
|
||||||
set frame_text " [$frame] $msg"
|
set frame_text " [$frame] $msg"
|
||||||
|
|
||||||
printf '%s' $frame_text
|
printf '%s' $frame_text
|
||||||
|
@ -126,8 +128,8 @@ function execute -a cmds msg
|
||||||
|
|
||||||
set_trap EXIT kill_all_subproccesses
|
set_trap EXIT kill_all_subproccesses
|
||||||
|
|
||||||
eval "$cmds" &>/dev/null 2>$tmp_file &
|
fish -c "$cmds" >/dev/null 2>$tmp_file &
|
||||||
set cmds_pid $fish_pid
|
set cmds_pid (jobs -lp)
|
||||||
|
|
||||||
show_spinner $cmds_pid $cmds $msg
|
show_spinner $cmds_pid $cmds $msg
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue