Intro
Total Commander provides commandline interface, so in order to open desired folder in Total Commander from Powershell or Windows Terminal you need to run:
1 |
"C:\totalcmd\TOTALCMD64.EXE" /O /T /L="C:\Directory\To\Open" |
But who wants to write that long stuff all over again.
Solution
Solution is, as usual, very simple. You have to add function, to your powershell profile. Keep in mind that Windows Powershell(until version 5.1) and PowerShell Core have their own profile file, so edit both of them or just your prefered version.
- Powershell Core profile file can be found in
C:\Users\#User#\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
. - Windows Powershell profile file can be found in
C:\Users\#User#\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
.
To get profile path just write $PROFILE
in terminal and hit ENTER. If you are using Visual Studio Code, run code $PROFILE
, this will open profile file in VS Code.
While editing Microsoft.PowerShell_profile.ps1
just paste following function and restart terminal.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function tcmd { param( [Parameter(Mandatory = $false, Position = 0)] [string]$FolderPath = $PWD, [Parameter(Mandatory = $false, Position = 1)] [Alias('r')] [switch]$RightPane ) if($RightPane){ $pane = "R" } else{ $pane = "L" } # Make sure you have correct path to TOTALCMD64.EXE # You can add, remove or change parameters & "C:\totalcmd\TOTALCMD64.EXE" /O /T /$pane="$FolderPath" } |
Make sure you change C:\totalcmd\TOTALCMD64.EXE
path to your Total Commander directory.
This function opens given path in new tab in Total Commander and it also doesn’t open new window if commander is already running. You can change this behaviour by altering parameters /O /T ...
. You can see all parameters here.
Usage
Use following snippets while in powershell or Windows Terminal.
Open current directory
1 |
tcmd |
Open C:\Program Files (x86) in right pane
1 |
tcmd "C:\Program Files (x86)" -r |