X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; q=dns; s=default; b=dH hUjEEXlL4W5cXp61RkAHj/iqIbyPKLumTRdoCMZCDOGyu2tT+r+4xfgTMWyf/m8x zFS4wL1S9FmoxNVaT66aJe/7cmWQyeOSqcdP9XFSKtVD0IV2cA2aDCxMnNwNW4fB /mluDUF1yLS0RrgbItI+gije3YCS3mDHcK2RrrjE0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; s=default; bh=UM8/I9BB dO8yjZDsEzdxeY6MkTM=; b=wUqFy43ctPTWoyAc02V96mh2pUTTT79qk++IxaL8 6T6Trpr2CvQ6p2TgIx7q1pgH/QpEiVCcALHvhHWWUaXPNns75OaCyGujr2Co6ln9 phjxA4QxuCkO0/jpul9PNUrmktu39dmpF3YKwTDd1sDNOVvK0hiKyFeeJjW6EmqN coU= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f177.google.com MIME-Version: 1.0 X-Received: by 10.42.206.210 with SMTP id fv18mr8980985icb.47.1412292243448; Thu, 02 Oct 2014 16:24:03 -0700 (PDT) In-Reply-To: References: <1576090815 DOT 20141002032152 AT yandex DOT ru> <542CB798 DOT 8000800 AT cs DOT umass DOT edu> <542CB963 DOT 4010004 AT redhat DOT com> <6CF2FC1279D0844C9357664DC5A08BA20EC1B6C8 AT MLBXV06 DOT nih DOT gov> Date: Thu, 2 Oct 2014 17:24:03 -0600 Message-ID: Subject: Re: Direct/efficient way to chop off trailing \n From: Keith Christian To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes You're welcome, Paul. But I see some streamlining that could be done since I wrote that xx() alias long ago. I do like Barry's "cygpath -aw foo/bar | putclip -d" as it likely runs faster. On Thu, Oct 2, 2014 at 12:20 PM, Paul.Domaskis wrote: > Keith Christian wrote: >> This function echoes the present directory to the clipboard, so that >> I don't have to enter the path manually. >> >> I use this function in a script that sources when a bash shell is >> started. Also echoes the path to the terminal for verification. >> Handy for pasting directly into windows file dialogs. >> >> function xx() { >> DESCRIPTION="Copy the Windows drive/path/filename to the > clipboard" >> cygpath -w "`pwd`"|tr -d "\012"|sed -e >> 's/$/\\/'|putclip;echo;getclip;echo >> } > > Thanks, Keith. I think it will be educational for me just to figure > this out. > > Andrey Repin wrote: >> Most people either use Cygwin tools in isolation, or use Cygwin >> tools from Windows tools. The opposite is rare, and mostly boils >> down to scripting, where you naturally use $(cygpath ...) to produce >> desired results. > > Which I find odd. If you like bash, then that's going to be your > explorer, and I am *never* able to work exclusively in cygwin. > > I suppose you can always use cygstart to launch app files > or executables, but Windows can be very inconsistent at times. I > never know when cygstart will launch a new instance of an > already-running app. Also, I often encounter the need to specify a > file location but not emulate a double-click on that file. > >>> So I can see why such a [\n chopping] switch has never been >>> developed. It's probably only needed for cygwin users, as it is >>> the *unixy crowd that uses both Windows & *nix at the same time. >> >> The cygpath tool is Cygwin specific :) So there's no contradiction >> to your words. > > Yeah, I suppose that was a circular truth. I should have said that > outside of cygwin, few people need to operate in both the POSIX and > Windows world at the same time. I guess those cases would be the ones > in which cygpath is used, and those are also the cases in which it > would be handy to have \n chopping capability built in to cygpath. > > Eliot Moss wrote: >> You could write my solution as: >> >> echo -n `cygpath -aw foo`>/dev/clipboard >> >> though the ` (backtick) notation is deprecated these >> days and $(...) is described as preferred. But for many >> little things like these I write bash functions (or >> aliases, when they work, which they don't here). > > Yeah, it's from decades ago, when I started dabbling in unix. > >> The echo solution has the good property that echo is >> a shell built-in and so does not require spawning >> another process. You had complained about speed, so >> even though the echo approach does not seem to top >> you list for elegance, it might for performance > > Eric Blake wrote: >> The same is true of printf. > > I don't care about the computational speed, I probably won't notice > any difference. I care about reducing it to the simplest sequence of > actions for the user, not only in terms of keystrokes, but also the > cognitive simplicity of the code (which is pretty subjective, I know). > I will give you code idiom a try. Thanks. > > Eric Blake wrote: >> 'echo -n' is not portable (in fact, you can disable it in bash, and >> it may misbehave if cygpath outputs a leading - or contains any \); >> it's better to use 'printf' for that purpose: >> >> printf %s `cygpath -aw foo`>/dev/clipboard > > A new bash command of which I was not aware. Thanks! > > Buchbinder, Barry wrote: >> Converting \n line endings to \r\n might work for you when you paste >> into a Windows app. It does for me. >> >> cygpath -aw foo/bar | putclip -d > > This is awesome! Even better than > > cygpath -aw foo/bar | unix2dos > /dev/clipboard > > Thanks a million!!! > > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple