A simple command counter

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
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.
Likes: hughntx
Many, many years ago, back when I was using 4DOS, it was either Charles or Rex who provided me with a method to "imitate" the bash shell prompt, giving a prompt that shows the command count. I am still using it.

I have an alias defined as;
plc=set plc=%@inc[%plc]
In my 4start.btm, I have;
PROMPT=`%_cmdproc:%_pid:%@exec[@plc] %plc $g `