this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add streaming output via FIFO + animated spinner

馃 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

alice d4d73a90 f2392dad

+43 -15
+43 -15
widget.zsh
··· 7 7 local input="$BUFFER" 8 8 local spin='鉅嬧牂鉅光牳鉅尖牬鉅︹牕鉅団爮' 9 9 10 - # Start CLI in background, write to temp file 11 - local tmpfile=$(mktemp) 12 - ( echo "$input" | bun "$_NLCMD_SCRIPT_DIR/cli.ts" 2>/dev/null > "$tmpfile" ) &! 10 + # Use a FIFO for streaming 11 + local fifo=$(mktemp -u) 12 + mkfifo "$fifo" 13 13 14 + # Start CLI in background, write to FIFO 15 + ( echo "$input" | bun "$_NLCMD_SCRIPT_DIR/cli.ts" 2>/dev/null > "$fifo" ) &! 14 16 local pid=$! 15 17 16 - # Animate spinner while waiting 17 - local i=0 18 - while kill -0 $pid 2>/dev/null; do 19 - BUFFER="$input ${spin:$((i % 10)):1}" 20 - CURSOR=${#BUFFER} 21 - zle redisplay 22 - sleep 0.05 23 - ((i++)) 18 + # Open FIFO for reading (non-blocking setup) 19 + exec {fd}<"$fifo" 20 + 21 + local char i=0 first=1 22 + 23 + while true; do 24 + if read -r -k 1 -u $fd -t 0.05 char 2>/dev/null; then 25 + if [[ $first -eq 1 ]]; then 26 + BUFFER="" 27 + first=0 28 + fi 29 + BUFFER+="$char" 30 + CURSOR=${#BUFFER} 31 + zle redisplay 32 + else 33 + local ret=$? 34 + # Check if process is still running 35 + if ! kill -0 $pid 2>/dev/null; then 36 + # Process done, drain remaining 37 + while read -r -k 1 -u $fd char 2>/dev/null; do 38 + if [[ $first -eq 1 ]]; then 39 + BUFFER="" 40 + first=0 41 + fi 42 + BUFFER+="$char" 43 + done 44 + break 45 + fi 46 + # Still waiting - show spinner 47 + if [[ $first -eq 1 ]]; then 48 + BUFFER="$input ${spin:$((i % 10)):1}" 49 + CURSOR=${#BUFFER} 50 + zle redisplay 51 + ((i++)) 52 + fi 53 + fi 24 54 done 25 55 26 - BUFFER="$(cat "$tmpfile")" 27 - CURSOR=${#BUFFER} 28 - rm -f "$tmpfile" 29 - zle redisplay 56 + exec {fd}<&- 57 + rm -f "$fifo" 30 58 } 31 59 32 60 zle -N nlcmd