Welcome!

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

SignUp Now!

How to? Maintain command line history between reboots

Jul
9
0
Hi.

I'm trying to keep command line history between reboots with shralias.
Currentlly I have logging enabled and tcstart.cmd file with this:
echo off
ShrAlias 2>> NUL
color green on bri white
echo on

Attached config file.
it works fine for one windows session, but i after i reboot there is no history available.

I'm on win7 x64 sp1 TCC LE 13.04.63, running under admin account with no uac.

Thanks, Oleg.
 
attaching a file doesn't seem to work so here it is inline:

[4NT]
ProxyPort=80
FirewallType=None
FirewallPort=1080
PassiveFTP=Yes
FTPTimeout=180
HTTPTimeout=180
TFTPTimeout=180
MailPort=25
RLocalPort=0
SHLocalPort=0
SSHPort=22
SSLStartMode=0
SSLPort=0
AmPm=No
BeepFreq=440
BeepLength=2
CommandSep=&
DecimalChar=Auto
DescriptionMax=512
NTFSDescriptions=No
Descriptions=Yes
EscapeChar=^
EvalMax=10
EvalMin=0
ExpandPseudovariables=Yes
ParameterChar=$
RegularExpressions=Perl
SwitchChar=/
TabStops=8
ThousandsChar=Auto
AutoCancel=No
AutoCDD=Yes
AutoRun=Yes
BatchAliases=Yes
BatchEcho=Yes
CMDExtensions=No
CopyPrompt=No
DelayedExpansion=No
DelGlobalQuery=Yes
DirJunctions=Yes
DuplicateBugs=Yes
ExecWait=No
HistLogName=C:\Users\OlegYch\AppData\Local\JPSoft\TCHistoryLog
HistLogOn=Yes
LocalAliases=No
LocalDirHistory=No
LocalFunctions=No
LocalHistory=No
LogAll=No
LogName=C:\Users\OlegYch\AppData\Local\JPSoft\TCCommandLog
LogOn=Yes
LogErrors=Yes
LogErrorsName=C:\Users\OlegYch\AppData\Local\JPSoft\TCErrorLog
MouseWheel=Yes
NoClobber=No
PathExt=No
Perl=No
Python=No
RecycleBin=No
Rexx=No
Ruby=No
SettingChange=No
SHChangeNotify=No
Tcl=No
UnicodeOutput=Yes
UnixPaths=Yes
UpdateTitle=Yes
WebHelp=No
Win32SFNSearch=No
Wow64FsRedirection=Yes
ZoneId=0
ANSI=No
CDDWinLeft=20
CDDWinTop=20
CDDWinWidth=300
CDDWinHeight=140
PopupWinHeight=400
PopupWinTop=10
PopupWinLeft=40
PopupWinWidth=400
WindowHeight=0
WindowState=Standard
WindowWidth=0
WindowX=0
WindowY=0
Transparency=255
InactiveTransparency=255
AppendToDir=Yes
CompleteHiddenFiles=Yes
CompleteHiddenDirs=Yes
CompletePaths=Yes
CompletePercents=No
CursorIns=100
CursorOver=15
DirHistory=12288
DirHistoryOnEntry=No
EditMode=InitInsert
FuzzyCD=0
HistMin=0
History=28672
HistCase=No
HistCopy=No
HistDups=Off
HistMove=No
HistWrap=Yes
ServerCompletion=Local
[PopupFont]
Font=Consolas
Size=-12
Weight=400
Italic=0
Script=204
 
Hello Oleg,

corresponding to tcstart.btm you can use a tcexit.btm.
So in tcstart you can issue
Code:
history /r myhistory.log
log  /h /w myhistory.log
and in the tcexit
Code:
history > myhistory.log

HTH
 
Hi Frank, thanks for the hint!
So I don't need to use shralias in this case? i'm ok if the history is not shared between several sessions running at the same time (actually i'd prefer this behavior)
if i don't run shralias and run several sessions will the history of the last closed session overwrite other sessions histories?

i'm trying to duplicate default bash behavior...
 
I know that SHRALIAS will save its state to disk when it exits if you set an environment variable SHRALIAS_SAVE_PATH. However, I don't know what the best way is to reload those files at startup. (I don't use any global lists myself, and I wouldn't want histories to survive a reboot.)
 
Oleg,
I have not used or tested it before.
I propose you figure it out and give us the result ;)
 
Hi Frank, thanks for the hint!
So I don't need to use shralias in this case? i'm ok if the history is not shared between several sessions running at the same time (actually i'd prefer this behavior)
if i don't run shralias and run several sessions will the history of the last closed session overwrite other sessions histories?

i'm trying to duplicate default bash behavior...
I have never used bash, I can go only on what you wrote in this thread.

If you want individual command histories for concurrent TCC instances, you need to do all of the following:
1/ make command histories local - start TCC.EXE with the /LH option (or set the corresponding directive in your .INI configuration file using the OPTION dialog)
2/ use tcstart.btm to
2.1/ load the history of the previous session: HISTORY /R logfile
2.2/ specify a command log file: LOG /H /W logfile

You do not need to run SHRALIAS for this operation, nor do you need to explicitly save history in TCEXIT - it will all be there in the logfile, which can grow to be infinitely large.

However, you run into the issues that
1/ you want to generate a unique name for the history file for each concurrent instance, and
2/ how do you find out which one of them to load when a new instance is started.

Issue 1/ is why you need to generate the log file name in TCSTART.BTM - cannot use the configuration directives. One simple method is to use files history.000 ... history.nnn where you set the limit how many different files you want (nnn+1), and use the advanced capabilities of TCC to assign the next available one.
 
You do not need to run SHRALIAS for this operation, nor do you need to explicitly save history in TCEXIT - it will all be there in the logfile, which can grow to be infinitely large.
Of course my advice with tcexit was saying the same thing twice over.
 
Thanks, guys!

Using /lh with HISTORY /R logfile and LOG /H /W logfile seems to do exactly what i want.
Every command gets appended into log so when i open a new shell every command gets loaded, but the commands entered in current shell don't affect other currently running sessions.

Thanks again, Oleg.
 

Similar threads

Back
Top