- Jan
- 38
- 0
I have been trying to follow the instructions for saving aliases without success. I would like to save an alias in such a way as to cause it to be operational automatically on startup of Take Command. I would be grateful for advice.
By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!iff %_shralias eq 0 then
shralias
alias /R %JPPath\DAT\alias.dat
iff %_cmdproc NE TCCLE then
function /R %JPPath\DAT\function.dat
endiffendiff
edal=in %_startpath\..\DAT start /wait notepad %_startpath\..\DAT\alias.dat & alias /r %_startpath\..\DAT\alias.dat
In my tcstart.btm is this code:That makes sure shralias is running, loads the aliases and, if not TCC/LE, loads the functions also. One of those aliases is this:Code:iff %_shralias eq 0 then shralias alias /R %JPPath\DAT\alias.dat iff %_cmdproc NE TCCLE then function /R %JPPath\DAT\function.dat endiffendiff
edal is short for edit alias. It edits the alias file and reloads those aliases.Code:edal=in %_startpath\..\DAT start /wait notepad %_startpath\..\DAT\alias.dat & alias /r %_startpath\..\DAT\alias.dat
Not at all. Here's a version (with comments):Wow! How complicated! I will have to find out what all this means.
REM I have D:\JPSoft\TCMD15\ and D:\JPSoft\DAT\ where alias and function files are.
REM Set JPPath to the folder above where my TCC is (D:\JPSoft).
set /e JPPath=%@full[%@path[%_cmdspec]..\]
iff %_shralias eq 0 then (If shralias is not loaded)
shralias (load shralias)
alias /R %JPPath\DAT\alias.dat (load aliases)
iff %_cmdproc NE TCCLE then (If my TCC is the full version and not TCC/LE)
function /R %JPPath\DAT\function.dat (load functions)
endiff
endiff
edal=in %_startpath\..\DAT start /wait notepad %_startpath\..\DAT\alias.dat & alias /r %_startpath\..\DAT\alias.dat
Look into setlocal/endlocal. It allows for global aliases, but your .btm can redefine them without affecting the shared aliases. Setlocal is usually the second line of my .btm files, right after @echo off. If the .btm does a setlocal, when it exits, it will do an endlocal automatically; no need to call it explicitly.I think I switched long ago to local aliases because with global aliases, any changes to aliases a btm file makes affects all the tabs. My btm files usually delete all aliases and then define just the ones they need. This way they aren't dependent on my general aliases (which I may change).
Look into setlocal/endlocal. It allows for global aliases, but your .btm can redefine them without affecting the shared aliases. Setlocal is usually the second line of my .btm files, right after @echo off. If the .btm does a setlocal, when it exits, it will do an endlocal automatically; no need to call it explicitly.
Though I've been using TCC since it was 4DOS (20+years?), I don't recall ever globally zapping all aliases in a batch file. I certainly define/clear some, but not '*'. I know being a lazy developer is a good thing (I certainly try), but are the .btms that complicated that the aliases used cannot be tracked? Even my multi-process synched .btms didn't reach that level.Yes, but if you execute "*UNALIAS *" within SETLOCAL, it will still remove all aliases from all other running TCC tabs until you perform the corresponding ENDLOCAL.
realias=alias | sort > %@path[%comspec]alias.ini %+ unalias * %+ alias /r %@path[%comspec]alias.ini
I actually once aliased something that wan't aliased before and broke a btm file. Rather than put "*" in front of everything in my btm files, I decided to do "unalias *". I'm not going to search all my btm files every time I fiddle with my aliases to make sure there aren't conflicts.Though I've been using TCC since it was 4DOS (20+years?), I don't recall ever globally zapping all aliases in a batch file. I certainly define/clear some, but not '*'. I know being a lazy developer is a good thing (I certainly try), but are the .btms that complicated that the aliases used cannot be tracked? Even my multi-process synched .btms didn't reach that level.
Thanks, but I did learn about setlocal a decade or two ago. My btm files usually start withLook into setlocal/endlocal. It allows for global aliases, but your .btm can redefine them without affecting the shared aliases. Setlocal is usually the second line of my .btm files, right after @echo off. If the .btm does a setlocal, when it exits, it will do an endlocal automatically; no need to call it explicitly.
*on errormsg cancel
*setlocal
*unalias *
Sorry if I confused you with the OP.Thanks, but I did learn about setlocal a decade or two ago.
No problem.Sorry if I confused you with the OP.
if %_pipe != 0 .or. %_transient != 0 .or. %_ide != 0 quit
alias /r c:\jpsoft\aliases
color bri yellow on black
set s=Y
inkey /c /k"YN[Enter]" /w10 /x Restore Previous Environment? (Yn) %%s
echo.
iff "%s" eq "Y" .OR. "%s" eq "@28" then
for %%s in (@c:\JPSOFT\drives.dat) do cdd %%s
set /r c:\JPSOFT\env.dat
dirhistory /r c:\JPSOFT\dirhist.dat
history /r c:\jpsoft\history.dat
endiff
set TREEEXCLUDE=d:\;e:\;f:\;g:\;h:\;I:\;J:\;K:\;L:\;M:\;N:\;O:\;P:\;Q:\;R:\;S:\;T:\;U:\;V:\;W:\;X:\;Y:\;Z:\;\\*\*
set TITLEPROMPT=%[_cmdproc]%@if[%_x64,x64,] %_4ver (%_BUILD) in %%_cwd
title %[_cmdproc]%@if[%_x64,x64,] %_4ver (%_BUILD)
prompt=`^e[37;%@if[%@remote[%_disk] eq 0,42,41];1m[$P]^e[33;40;1m$s`
unset s
This is disturbing. How could this not be considered a bug? I thought things like this is exactly what SETLOCAL/ENDLOCAL is to protect against?Yes, but if you execute "*UNALIAS *" within SETLOCAL, it will still remove all aliases from all other running TCC tabs until you perform the corresponding ENDLOCAL.
If you want to use global aliases, then it is at least a missing feature. If you use local aliases, then setlocal works fine.This is disturbing. How could this not be considered a bug? I thought things like this is exactly what SETLOCAL/ENDLOCAL is to protect against?
I find that my alias list changes very rarely. I tend to forget what I've created anyway so I don't have a very long alias list. I use David Marcus's approach - i.e. I save to a file when I want to update my persistent alias list. And I load the file in TCSTART.BTM.
Here is my complete TCSTART file
Code:if %_pipe != 0 .or. %_transient != 0 .or. %_ide != 0 quit alias /r c:\jpsoft\aliases color bri yellow on black set s=Y inkey /c /k"YN[Enter]" /w10 /x Restore Previous Environment? (Yn) %%s echo. iff "%s" eq "Y" .OR. "%s" eq "@28" then for %%s in (@c:\JPSOFT\drives.dat) do cdd %%s set /r c:\JPSOFT\env.dat dirhistory /r c:\JPSOFT\dirhist.dat history /r c:\jpsoft\history.dat endiff set TREEEXCLUDE=d:\;e:\;f:\;g:\;h:\;I:\;J:\;K:\;L:\;M:\;N:\;O:\;P:\;Q:\;R:\;S:\;T:\;U:\;V:\;W:\;X:\;Y:\;Z:\;\\*\* set TITLEPROMPT=%[_cmdproc]%@if[%_x64,x64,] %_4ver (%_BUILD) in %%_cwd title %[_cmdproc]%@if[%_x64,x64,] %_4ver (%_BUILD) prompt=`^e[37;%@if[%@remote[%_disk] eq 0,42,41];1m[$P]^e[33;40;1m$s` unset s
If you want to use global aliases, then it is at least a missing feature. If you use local aliases, then setlocal works fine.
Thanks, seems like a reasonable workaround!This is very easy to deal with. Just put the command "alias /L" before the "unalias *" command to switch from global aliases to local aliases. Then the "unalias" command will only clear the local aliases in the batch file, and no other TCC sessions will be affected. After "endlocal" the aliases will come back.