delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/28/18:09:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3EFE120B.58A0C79E@dessent.net>
Date: Sat, 28 Jun 2003 15:09:15 -0700
From: Brian Dessent <brian AT dessent DOT net>
Organization: My own little world...
X-Accept-Language: en,pdf
MIME-Version: 1.0
To: Soren A <somian AT adelphia DOT net>
CC: cygwin AT cygwin DOT com
Subject: Re: example needed pls: `cygpath -c <HANDLE>'
References: <Xns93A88A37D41F9soren1Gmane AT 80 DOT 91 DOT 224 DOT 249>

Soren A wrote:

>   * yeah,  am using AS Perl, that's because this is a piece of
>     a WSH script.
>   * what I'd like to end up with is a way to context|alternate-click
>     on any filename in MSWindows Explorer and place the filename as
>     *cygwin*, not the OS, will see it, on the clipboard. Anyone
>     already had a pass at this wheel?

I was playing around with this because it seems like a handy idea.  
I use Cywin perl, but the differences shouldn't be very great.  Anyway, 
I came up with the following oneliner that does what you mention above 
(passed %1 as a Windows filename, it copies the Cygwin version to the
clipboard)

c:\cygwin\bin\perl.exe -MWin32::Clipboard -e "my $f=quotemeta('%1'); chomp (my $c=qx!cygpath -u $f!); Win32::Clipboard($c);"

If you install the following registry entries, you get a context menu 
for files and directories that runs this when selected.  You should be
able to save this as a .REG file and click on it to import the entries,
you'd have to change the path to perl though.

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\CygPath]
@="&Copy Cygwin Path"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\CygPath\Command]
@="c:\\cygwin\\bin\\perl.exe -MWin32::Clipboard -e \"my $f=quotemeta('%1'); chomp (my $c=qx!cygpath -u $f!); Win32::Clipboard($c);\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\CygPath]
@="&Copy Cygwin path"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\CygPath\command]
@="c:\\cygwin\\bin\\perl.exe -MWin32::Clipboard -e \"my $f=quotemeta('%1'); chomp (my $c=qx!cygpath -u $f!); Win32::Clipboard($c);\""

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019