File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 33input=$( cat)
44
55MODEL=$( echo " $input " | jq -r ' .model.display_name' )
6+ TOTAL=$( echo " $input " | jq -r ' .context_window.context_window_size // 0' )
67PCT=$( echo " $input " | jq -r ' .context_window.used_percentage // 0' | cut -d. -f1)
8+ USED=$(( PCT * TOTAL / 100 ))
79
8- BAR_WIDTH=10
9- FILLED=$(( PCT * BAR_WIDTH / 100 ))
10- EMPTY=$(( BAR_WIDTH - FILLED))
11- BAR=" "
12- [ " $FILLED " -gt 0 ] && BAR=$( printf " %${FILLED} s" | tr ' ' ' ▓' )
13- [ " $EMPTY " -gt 0 ] && BAR=" ${BAR} $( printf " %${EMPTY} s" | tr ' ' ' ░' ) "
10+ fmt_k () {
11+ local n=$1
12+ if [ " $n " -ge 1000000 ]; then
13+ echo " $(( n / 1000000 )) M"
14+ elif [ " $n " -ge 1000 ]; then
15+ echo " $(( n / 1000 )) k"
16+ else
17+ echo " ${n} "
18+ fi
19+ }
20+
21+ USED_FMT=$( fmt_k " $USED " )
22+ TOTAL_FMT=$( fmt_k " $TOTAL " )
1423
1524CWD=$( echo " $input " | jq -r " .workspace.current_dir" )
1625DIR=$( basename " $CWD " )
1726BRANCH=$( git rev-parse --git-dir > /dev/null 2>&1 && git branch --show-current 2> /dev/null)
1827
19- echo " [ $MODEL ] $BAR $ PCT% | $DIR ${BRANCH: + ($BRANCH )} "
28+ echo " $MODEL · ${USED_FMT} / ${TOTAL_FMT} ( ${ PCT} %) · $DIR ${BRANCH: + ($BRANCH )} "
You can’t perform that action at this time.
0 commit comments