rem 1. Create a variable to hold the count: set ncmd=0 rem 2. Show this variable in the prompt: prompt `[%ncmd] $P$g` rem 3. Increment the count after each command: alias post_exec=`set ncmd=%@inc[%ncmd]`
Note the use of backquotes to prevent variables and functions from being expanded prematurely.