Welcome!

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

SignUp Now!

Change Default Prompt

Feb
5
0
I know that in Windows itself you can change the default command prompt so when you execute prompt from the command line you get your own default prompt instead of the default $p$g, However I haven't figured out how to do it in Take Command nor TCC.

How do you change it so that if I do prompt for the TCC command line, I get my prompt not [C:\]. I have color and several things added.

Thank you,

George
 
Create a file TCSTART.BTM in the directory where Take Command is installed. Put the commands you want to run at startup there: your prompt for sure, maybe load aliases from a file, stuff like that.
 
I know that in Windows itself you can change the default command prompt so when you execute prompt from the command line you get your own default prompt instead of the default $p$g, However I haven't figured out how to do it in Take Command nor TCC.

How do you change it so that if I do prompt for the TCC command line, I get my prompt not [C:\]. I have color and several things added.

Thank you,

George

George:

Follow @Charles Dye 's advice. However, let me add to that. I'd recommend that you put your "prompt setter" and your aliases and other things like that in their own separate files. Then use CALL to run those files from TcStart.btm -- except for things like aliases or history, which you'll (obviously) just load from their respective files.

Here is a batch file that can set several different fancy prompts.

Probably not even close to the prompt you want, but it's a starting point you can hack up. If you haven't already, read up about ANSI Escape Sequences in the Take Command HELP. You should be able to hack this file to make it do what you want it to do. Or you can just steal little snippets and paste them into your own batchfile.

An Apology, Though: this file is at least 25 years old. I've been maintaining it all this time! However... that means there is a lot of cruft left over in it from much earlier versions of JpSoft. (This was originally used for 4DOS and has followed me through 4NT, 4OS2, and Take Command!) So not everything is done the best way, and there's stuff that's long since been rendered unnecessary (stripping 'a' or 'u' off the version number, for instance).
 
This is what some of the prompts look like:

1638544872589.png


The length that triggers an elided path can of course be tweaked in the code.
As can the length that it reduces to. I have both of mine set somewhat wide.
 
Last edited:
As you probably know, there is also TITLEPROMPT. That's where I put fairly static info (version, ProcessId, CWD).

1638547700950.png
 
Forgot above that the elider is in a separate batch file.
Also, you'll need the _SH setter if you want to use ColorPrompt.btm "as is."
 

Attachments

  • SetVar_sh.btm
    809 bytes · Views: 164
For some reason it's not letting me upload ELPATH.BTM.
Trying again. If it doesn't let me do it separately, I guess I'll have to post it as a code snippet?
 
Sigh...


Code:
:: ELPATH.BTM
:: For author, licensing, revision history, see the end of file.
@LOADBTM ON
@echo off

SETLOCAL

:: If not manually set by the user, set max prompt path length to a little more
:: than half the current width of the screen.  If PL is negative, assume we want
:: (screen width - |value|).  Do this INSIDE the setlocal so we leave the user's
:: value alone.  If not set in the external environment, it means this script
:: will adapt to current screen width every time.

iff "%PL" == "" then
    set PL=%@EVAL[%_columns / 1.9 =0.0]
else if %PL LT 0 then
    set PL=%@EVAL[ %_columns + %PL ]
endiff

:: Emit whole CWD if shorter than the max length.
iff %@LEN[%_CWD] LT %PL then
   echos %_CWD
   QUIT
endiff

:: This is the slower but SMARTER version that always prints INTACT subdir names
:: at the beginning and end of the shortened string...

:SMART_CODE
setlocal
:: Elision adds 4 characters, so eliding must save at least 5.
:: If you want to reduce the resulting width to something else,
:: this is the place to do it.
set PL=%@EVAL[%PL - 5]
:: Start with the leftmost and rightmost directories in the CWD.
set lhs=%@WORD["\\",0,%_CWD]
set rhs=%@WORD["\\",-0,%_CWD]
set cnt=%@WORDS["\\",%_CWD]
:: Now, build the elided path by alternately adding directories to the left
:: part (LHS) and then the right part (RHS) until either would push us over
:: the limit.
do i = 1 to %cnt
   if %@LEN[%lhs %rhs] GE %PL LEAVE
   set lh2=%@WORD["\\",%i,%_CWD]
   if %@LEN[%[lhs]\%[lh2]\%[rhs]] GE %PL LEAVE
   set lhs=%[lhs]\%lh2
   set rh2=%@WORD["\\",-%i,%_CWD]
   if %@LEN[%lhs\%rh2\%rhs] GE %PL LEAVE
   set rhs=%[rh2]\%[rhs]
enddo
:: At this point we should have a left-hand-side and a right-hand-side that we
:: can concatenate together with the elision: left+dots+right. (Two dots are
:: sufficient for the user to get the idea.)  NOTE: the (len-5) here is a safety
:: net, separate from the MaxPathLen calculation above, and it should not be
:: changed here.
iff %@LEN[%lhs %rhs] LT %@EVAL[%@LEN[%_CWD] - 5] then
   switch "%_dos"
      case "WIN32" .or. "NT" .or. "WIN2K" .or. "WINXP" .or. "WINDOWS10"
         echos %[lhs]\úú\%[rhs]
      default
         echos %[lhs]\··\%[rhs]
   endswitch
else
    echos %_CWD
endiff

ENDLOCAL
QUIT



:: This is the simpler and faster version that just chops out the middle
:: and replaces it with a ".." elipsis.  On much older machines, this made
:: a noticable difference in speed, but in 2021 there's really no reason
:: to use this.
:DUMB_CODE
set LL=%@EVAL[(%PL - 1) / 2.1 =0.0]
set NewWidth=%@EVAL[%LL*2 + 2 =0.0]
set OldWidth=@LEN[%CWD]
iff %LL GT 3 then
    switch "%_dos"
       case "WIN32" .or. "NT" .or. "WIN2K" .or. "WINXP" .or. "WINDOWS10"
          echos %@LEFT[%LL,%_cwd]úú%@RIGHT[%LL,%_cwd]
       default
          echos %@LEFT[%LL,%_cwd]··%@RIGHT[%LL,%_cwd]
    endswitch
else
    echos %_CWD
endiff
ENDLOCAL
QUIT


::
:: =============================================================================
:: AUTHOR
::      John T. Baldwin
:: LICENSING
::      Licensed to my fellow JpSoft users under the MIT Open Source License.
::      Please maintain my original author's attribution and any revision history
::      of mine or your own.
:: =============================================================================
:: MODIFICATION HISTORY
:: =============================================================================
:: 2006-01-25 jtbaldwin    Created.
::
:: 2007-03-16 jtbaldwin    Simplified and sped up.
::                         Left the old code in but disabled.
::
:: 2019-12-17 jtbaldwin    Improved the old code so elision is smarter and
::                         better balanced.  Added check for Windows 10.
::                         Machines are so much faster now, there's no reason
::                         to use the simpler, dumber code, but I left it in
::                         place in case I want to go back to it for some odd
::                         reason.
::
:: 2020-01-16 jtbaldwin    Moved sections around to remove GOTO which slows
::                         things down a bit without benefit.
::
:: =============================================================================
 
Back
Top