Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

A simple command counter

Charles Dye

Super Moderator
May
5,028
133
Staff member
Code:
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.
 
As an FYI, you don't need the inner %ncmd as @eval and @inc/@dec expect that to be a variable.
Code:
alias post_exec=`set ncmd=%@inc[ncmd]`
 
As an FYI, you don't need the inner %ncmd as @eval and @inc/@dec expect that to be a variable.

I think they actually call %@EVAL[] internally; you can do stuff like %@INC[6 * 9] and get sensible results.
 
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;
Code:
plc=set plc=%@inc[%plc]

In my 4start.btm, I have;
Code:
PROMPT=`%_cmdproc:%_pid:%@exec[@plc] %plc $g `

Joe
 
Back
Top
[FOX] Ultimate Translator
Translate