Smart cd in directory hotlist
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 20
- Joined: 2006-03-01, 21:33 UTC
- Contact:
Smart cd in directory hotlist
I'm trying to implement a smart relative shortcut in directory hotlist.
I work on a big code base with a lot of structure. And I have different branches checked out on my disk.
So first I used an environment variable like: %branch1% and %branch2%
then i can do: "cd %branch1%/server/plugin"
but what I would like to do is:
"smartcd server/plugin"
and smartcd is a script that finds the top of the branch I'm in and does a relative cd from there.
I already have the script, but can't in any way transfer that information to Total Commander. One rather simple solution would be if I could run two commands on the Directory Hotlist command line. Then the script could set an environment variable and the second command could be cd including that variable.
I almost found a solution using commandline arguments to TC. But then I had to choose which side of TC I should open the path in.
I work on a big code base with a lot of structure. And I have different branches checked out on my disk.
So first I used an environment variable like: %branch1% and %branch2%
then i can do: "cd %branch1%/server/plugin"
but what I would like to do is:
"smartcd server/plugin"
and smartcd is a script that finds the top of the branch I'm in and does a relative cd from there.
I already have the script, but can't in any way transfer that information to Total Commander. One rather simple solution would be if I could run two commands on the Directory Hotlist command line. Then the script could set an environment variable and the second command could be cd including that variable.
I almost found a solution using commandline arguments to TC. But then I had to choose which side of TC I should open the path in.
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
i did something similar (i had a "cd to newest sub directory") via script and
%commander_exe%" /O /S /L="targetdirectory"
always openened the directories in the active panel...
by the way: i dont understand from your posting whether you know that since last TC Release you can run multiple em_commands from one button. That could solve your "two commands" usage problem. I think it is also working for directory hotlist.
hope that helps a little.
%commander_exe%" /O /S /L="targetdirectory"
always openened the directories in the active panel...
by the way: i dont understand from your posting whether you know that since last TC Release you can run multiple em_commands from one button. That could solve your "two commands" usage problem. I think it is also working for directory hotlist.
hope that helps a little.
-
- Junior Member
- Posts: 20
- Joined: 2006-03-01, 21:33 UTC
- Contact:
Thanks
I did not now about a new "two commands" feature, I will take look at that.
But I don't understand what /L="targetdirectory" should do, /L always sets the left pane to that directory, but I want my Directory Hotlist item to work for both the right and left side unfortunately.
But perhaps I have to decide to always do this in either the right or the left pane or have one set of Directory Hotlist items for left panel and one set for the right...
I did not now about a new "two commands" feature, I will take look at that.
But I don't understand what /L="targetdirectory" should do, /L always sets the left pane to that directory, but I want my Directory Hotlist item to work for both the right and left side unfortunately.
But perhaps I have to decide to always do this in either the right or the left pane or have one set of Directory Hotlist items for left panel and one set for the right...
-
- Junior Member
- Posts: 20
- Joined: 2006-03-01, 21:33 UTC
- Contact:
2good_alias
(I don't have read and understood the whole thread, but..)
With "commands", TC commands are meant, like CM_xyz or EM_abc
To use your two commands in button,
first make a user command out of them, like
usercmd.ini
[em_rootBat]
cmd=cmd /c D:\rive\path\find_root.bat
[em_cdTest]
cmd=cd %test%
Then try in button:
em_rootBat, em_cdTest
But I guess the CD command could be in the bat as well?
Such commands will not work in Directory Hotlist at all.
(I don't have read and understood the whole thread, but..)
With "commands", TC commands are meant, like CM_xyz or EM_abc
To use your two commands in button,
first make a user command out of them, like
usercmd.ini
[em_rootBat]
cmd=cmd /c D:\rive\path\find_root.bat
[em_cdTest]
cmd=cd %test%
Then try in button:
em_rootBat, em_cdTest
But I guess the CD command could be in the bat as well?
Such commands will not work in Directory Hotlist at all.
-
- Senior Member
- Posts: 276
- Joined: 2011-11-15, 06:14 UTC
- Location: DE\BN - only part time TC user after switching to Linux ;)
No. Just try the commandgood_alias wrote:Thanks
I did not now about a new "two commands" feature, I will take look at that.
But I don't understand what /L="targetdirectory" should do, /L always sets the left pane to that directory, but I want my Directory Hotlist item to work for both the right and left side unfortunately.
But perhaps I have to decide to always do this in either the right or the left pane or have one set of Directory Hotlist items for left panel and one set for the right...

At least for me it always addresses the currently actibe panel. No matter if it is left or right.
I dont know from top of my head but one of the orher two switches cha ges the behavuor accordingly. Check the help. The commandline options are quite complex...
Regarding the Double command i was quite sure i have used it myself within hotlist.
-
- Junior Member
- Posts: 20
- Joined: 2006-03-01, 21:33 UTC
- Contact:
Well, I got it to work, kind of
the first, em_rootBat sets an environment variable, and since TC listens to environment changes, I can use that in the second command which does:
cd %test%
but this only works if I sleep 2 or 3 seconds in em_rootBat, after setting the environment variable.
And I can't do the cd command in the first command since, that will not change the current directory of TC (right?)
so any other bright ideas on how to do this?
the first, em_rootBat sets an environment variable, and since TC listens to environment changes, I can use that in the second command which does:
cd %test%
but this only works if I sleep 2 or 3 seconds in em_rootBat, after setting the environment variable.
And I can't do the cd command in the first command since, that will not change the current directory of TC (right?)
so any other bright ideas on how to do this?
PowerShell: change server
2good_alias
Are that %branch1% ones mapped drives? Or do we talk about UNC paths?
EDIT: not relevant question if we use PowerShell
Here is an example. Needs more thinking and to develop a nicer prompt.
Example:
TC Button or em_command: you will be prompted to modify wantedshare
cmd=PowerShell -NoExit -NoProfile -ExecutionPolicy Bypass
param=?D:\rive\path\to\root.ps1 '%P' wantedshare
root.ps1
Just a idea, POC.
Are that %branch1% ones mapped drives? Or do we talk about UNC paths?
EDIT: not relevant question if we use PowerShell
Here is an example. Needs more thinking and to develop a nicer prompt.
Example:
TC Button or em_command: you will be prompted to modify wantedshare
cmd=PowerShell -NoExit -NoProfile -ExecutionPolicy Bypass
param=?D:\rive\path\to\root.ps1 '%P' wantedshare
root.ps1
Code: Select all
#REM Get whole current path from TCs %P variable (first argument)
$oPath=$args[0]
#REM Get wanted branch from TCs second argument (type wanted text your own, overwrite 'wantedshare')
$wBranch=$args[1]
Write-Host Profided: $wBranch -AND- $oPath
#REM compute wanted path
$oBranch= split-path $oPath -qualifier
$wPath= ($oPath -replace($oBranch,$wBranch))
Write-Host New branch full path: $wPath
Write-Host "Press any key to continue ..."
#REM command to open $wPath in TC:
# todo...
#
#
#
Just a idea, POC.
Calling batch and then using envvar in TC is wrong because batch only changes envvars in its own environment. Setting global envvars in batch AFAIK requires third-party tools.
Most correct way was mentioned above: you should simply start a script (e.g. batch file) that will retrieve correct envvar and call TOTALCMD /O /S /L="path", it will pass a CD command to running TC instance.
Most correct way was mentioned above: you should simply start a script (e.g. batch file) that will retrieve correct envvar and call TOTALCMD /O /S /L="path", it will pass a CD command to running TC instance.
-
- Junior Member
- Posts: 20
- Joined: 2006-03-01, 21:33 UTC
- Contact: