Opening Cygwin Bash console from XYp?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
kartal
Posts: 208
Joined: 14 Aug 2008 18:06

Opening Cygwin Bash console from XYp?

Post by kartal »

Hi

I am trying to open Cygwin Bash console from XYp and I cannot get to anywhere :(
Here is the command to run it normally inside Windows

Code: Select all

C:\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe '%L'"
So I change it to

Code: Select all

C:\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe <curpath>"
and add to "open" commands, but it does not work nothing , no screen or shell opens for me :( Maybe someone can help me out here


thanks

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Opening Cygwin Bash console from XYp?

Post by nas8e9 »

kartal wrote:I am trying to open Cygwin Bash console from XYp and I cannot get to anywhere :(
Here is the command to run it normally inside Windows

Code: Select all

C:\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe '%L'"
This doesn't work for me at all (no screen, no error message) with a vanilla installation of the current Cygwin on Windows 7 x64.
So I change it to

Code: Select all

C:\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe <curpath>"
and add to "open" commands, but it does not work nothing , no screen or shell opens for me :(
I'd try it with the XYplorer variable outside the quotes like so:

Code: Select all

C:\cygwin\bin\bash -c "/bin/xhere /bin/bash.exe" <curpath>
I'm guessing that XYplorer treats everything within double quotes literally and thus doesn't recognise its own variable.

Finally, according to XYplorer's help on the "open" scripting command:
Note that the application must be double-quoted when command line parameters are used! If the whole argument is single-quoted, the contained double-quotes don't have to be doubled.
so:

Code: Select all

'"C:\cygwin\bin\bash" -c "/bin/xhere /bin/bash.exe" <curpath>'
I'm not sure how the double quotes in the bash parameter should be encoded given the single quotes around the whole parameter for the "open" function.

Unfortunately, even with the two changes above I couldn't get it to work. I know a little Linux but bash not so much, which doesn't help.

I hope *some* of the above is of use (or indeed at all relevant :mrgreen:).

Malkyne
Posts: 1
Joined: 19 Feb 2013 14:34

Cygwin current dir in XY: I have it working!

Post by Malkyne »

I know that this is an ancient thread, but I think I've got it working, and I wanted to post it up here, in case it helps someone else!

What you were missing in the above attempts is that you need a terminal window to open that bash up in. Cygwin uses mintty by default. So, I did some research, trying to figure out what the right string was to get what we wanted. The tricky part turned out to be that bash needed a path in a Cygwin-friendly unix format, so I had to do a bit of conversion on <curpath> to feed it in there.

But, it works! When I click on my Cygwin button, it opens a Cygwin mintty terminal window with a bash prompt, in the currently selected directory. I believe that "chere" provides "xhere" in the Cygwin packages, so make sure that's installed, for this to work.

This is my button code:

Code: Select all

$path = "/cygdrive/" . recase(substr("<curpath>", 0, 1), "lower") . replace(substr("<curpath>", 2), "\", "/"); open """D:\cygwin\bin\mintty.exe"" -e /bin/xhere /bin/bash.exe $path"
IMPORTANT NOTE: Don't forget to change that "D:\cygwin" part to the correct cygwin root on your own machine.

Happy XYploring!

admin
Site Admin
Posts: 65272
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Opening Cygwin Bash console from XYp?

Post by admin »

Wow, cool, thanks for that!

And welcome,
Don

lorddevi
Posts: 4
Joined: 03 Nov 2014 11:11

Re: Opening Cygwin Bash console from XYp?

Post by lorddevi »

Excellent!

I am loving Xyplorer so far I must say.

The above trick worked fine for me as well. However, it does not seem to open Cygwin in the current directory if my current path has any directories in it that include spaces.

Is there a way to tweak the above so that the $path variable expands to have double quotes around the path or something perhaps?

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Opening Cygwin Bash console from XYp?

Post by PeterH »

lorddevi wrote:Excellent!

I am loving Xyplorer so far I must say.

The above trick worked fine for me as well. However, it does not seem to open Cygwin in the current directory if my current path has any directories in it that include spaces.

Is there a way to tweak the above so that the $path variable expands to have double quotes around the path or something perhaps?
If I see it right, just try:

Code: Select all

$path = "/cygdrive/" . recase(substr("<curpath>", 0, 1), "lower") . replace(substr("<curpath>", 2), "\", "/"); open """D:\cygwin\bin\mintty.exe"" -e /bin/xhere /bin/bash.exe ""$path"""

Post Reply