Page 1 of 1

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

Posted: 2018-01-25, 19:56 UTC
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.

Posted: 2018-01-29, 15:20 UTC
by ghisler(Author)
Where should it accept them? When passed as parameters to TC?

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

Posted: 2018-01-29, 16:05 UTC
by gdpr deleted 6
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.

Posted: 2018-01-31, 15:40 UTC
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.

Posted: 2018-01-31, 16:21 UTC
by gdpr deleted 6
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...)

Posted: 2018-01-31, 17:01 UTC
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.

Posted: 2018-01-31, 17:11 UTC
by gdpr deleted 6
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?

Posted: 2018-02-01, 04:51 UTC
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.

Posted: 2018-02-01, 17:44 UTC
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?

Posted: 2018-02-01, 19:40 UTC
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.

Posted: 2018-02-01, 21:28 UTC
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

Posted: 2018-02-01, 21:40 UTC
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.