MSYS/Cygwin paths (i.e. /c/dir or /cygdrive/c/dir)

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
reinstein
Junior Member
Junior Member
Posts: 21
Joined: 2003-12-13, 11:54 UTC
Location: Israel

MSYS/Cygwin paths (i.e. /c/dir or /cygdrive/c/dir)

Post by *reinstein »

[Feature request]
Is it possible to enable TC to accept paths of the form /c/dir and /cygwin/c/dir, like the ones used in MSYS2 and Cygwin?

Thank you.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Where should it accept them? When passed as parameters to TC?
Author of Total Commander
https://www.ghisler.com
User avatar
elgonzo
Power Member
Power Member
Posts: 866
Joined: 2013-09-04, 14:07 UTC

Re: MSYS/Cygwin paths (i.e. /c/dir or /cygdrive/c/dir)

Post by *elgonzo »

What are you trying to do, what has TC to do with (virtual/mapped) paths that exist only within the shell/execution environments of msys/cygwin?
Your question (feature request) sounds a bit like a XY problem.
Begrudgingly back to Windows... now 11... sigh... but i have no nerve for Linux desktop anymore...
reinstein
Junior Member
Junior Member
Posts: 21
Joined: 2003-12-13, 11:54 UTC
Location: Israel

Post by *reinstein »

ghisler(Author) wrote:Where should it accept them? When passed as parameters to TC?
It seems like it is mostly effective at the command line, e.g. cd /c/dir,
or in a command parameters dialog.
My TC invocation is already in control (I can properly setup the startup environment).
Now, when I copy a path from a console and paste it into TC, here's when a transformation to Windows-formed path is required.
User avatar
elgonzo
Power Member
Power Member
Posts: 866
Joined: 2013-09-04, 14:07 UTC

Post by *elgonzo »

reinstein wrote:It seems like it is mostly effective at the command line, e.g. cd /c/dir,
or in a command parameters dialog.
What if i have the following directories on my machine (with drive C: being the current drive in the active file panel):

C:\c
C:\c\dir
C:\dir

When i use TC with the feature you suggested, what will happen? Do i get a surprise gift from Mr. Ghisler? ;) :twisted:

Joking aside, perhaps this could be resolved by not using the cd command, but by having a special command for this, like ccd ("Cygwin CD") perhaps.
(Not sure if the expected usability value of this feature will justify the expected implementation effort; but that is Mr. Ghisler's call...)
Begrudgingly back to Windows... now 11... sigh... but i have no nerve for Linux desktop anymore...
reinstein
Junior Member
Junior Member
Posts: 21
Joined: 2003-12-13, 11:54 UTC
Location: Israel

Post by *reinstein »

elgonzo wrote:
reinstein wrote:It seems like it is mostly effective at the command line, e.g. cd /c/dir,
or in a command parameters dialog.
What if i have the following directories on my machine (with drive C: being the current drive in the active file panel):

C:\c
C:\c\dir
C:\dir

When i use TC with the feature you suggested, what will happen? Do i get a surprise gift from Mr. Ghisler? ;) :twisted:

Joking aside, perhaps this could be resolved by not using the cd command, but by having a special command for this, like ccd ("Cygwin CD") perhaps.
(Not sure if the expected usability value of this feature will justify the expected implementation effort; but that is Mr. Ghisler's call...)
Path expressions of the form '/c/dir' are of little use in Windows systems. Thus, one can let TC transform them into 'c:/dir' (you may have this configuration dependent, of course).
Note that the purpose here is to allow consistency in the ecosystem TC is part of. A reasonable user would expect a 'cd' command to work properly in the described scenario given a sound transformation exists.
User avatar
elgonzo
Power Member
Power Member
Posts: 866
Joined: 2013-09-04, 14:07 UTC

Post by *elgonzo »

reinstein wrote:Path expressions of the form '/c/dir' are of little use in Windows systems.
Says who?
A reasonable user would expect a 'cd' command to work properly in the described scenario given a sound transformation exists.
Can you meaningfully describe that "sound transformation" you allude to?
Begrudgingly back to Windows... now 11... sigh... but i have no nerve for Linux desktop anymore...
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

reinstein wrote:Path expressions of the form '/c/dir' are of little use in Windows systems.
Windows accepts both forward and back slashes, and path in form \a\b\x\c is pretty valid - it points to a dir relative to the root of the current drive. So if I'm in D:\A\B\C, cd \c\dir or cd /c/dir changes dir to D:\c\dir, it is so in TC and even in cmd.exe.

I think that you need a separate button or command that will call some script that will fix the path for TC, it is not a TC task to convert any kinds of strange paths into normal ones. If you have path copied into clipboard, perhaps it will be useful to have a script that gets it there. You can even override cd command in TC command line in order to enable any custom path preprocessing, TC allows it.
reinstein
Junior Member
Junior Member
Posts: 21
Joined: 2003-12-13, 11:54 UTC
Location: Israel

Post by *reinstein »

MVV wrote:You can even override cd command in TC command line in order to enable any custom path preprocessing, TC allows it.
How would you do that?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Overriding cd command:
1. Configuration, Misc, Redefine hotkeys, Alias: cd, press command selection button.
2. In command browser window locate usercmd.ini category and add new command named e.g. em_CustomCd, fill program path and parameters depending on scripting environment and use %A placeholder where you want to get path that was passed to cd command, I'll use just cmd.exe as an example:

Code: Select all

Program: cmd.exe
Parameters: /c ""%%COMMANDER_EXE%%" /O /S /L="%Z%A""
3. Press OK and OK to close command editor and command browser, then click assign button (green checkmark) and OK to close Configuration window.

Now when you type cd something in TC command line, TC executes cmd.exe with parameters /c ""%%COMMANDER_EXE%%" /O /S /L="something"". So you can alter path in a script and pass it back to TC.
reinstein
Junior Member
Junior Member
Posts: 21
Joined: 2003-12-13, 11:54 UTC
Location: Israel

Post by *reinstein »

Thanks!
Definitely worth a TC-wiki entry.
BTW, what does the %Z stand for?

Will also work in the following setup (skipping the shell invocation):
Program: %COMMANDER_EXE%
Parameters: /O /S /L="%Z%A"

For diagnosis, the following is useful:
Program: cmd.exe
Parameters: /c "echo "%%COMMANDER_EXE%%" /O /S /L="%Z%A" & pause"

Note, however, that this by itself will not replace the original 'cd' command, as relative paths will not work.
A translation script can fix that.

Anyways, it still looks that internal TC support for MSYS/Cygwin paths is still worth considering.
I have gone cold turkey off cmd as an interactive shell, replacing it with conemu/bash combination (via msys/Cygwin).
Before that, I have also spent quite a while working with TakeCommand, but bash/zfs/fish seem to have better prospects right now.
But then, one should be able to paste funny paths into TC...

BR
reinstein
Junior Member
Junior Member
Posts: 21
Joined: 2003-12-13, 11:54 UTC
Location: Israel

Post by *reinstein »

reinstein wrote: Note, however, that this by itself will not replace the original 'cd' command, as relative paths will not work.
Will also break 'cd' inside archive files. This will not be easy to fix.
Post Reply