delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/10/01/18:08:53

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:date:from:to:subject:message-id:references
:mime-version:content-type:in-reply-to; q=dns; s=default; b=b3QG
lWmqwlWsvv0UapSAdjgQsuool64FQ+cIFaqxG+Rb+8qky1WYjcOlO1c6+aLQ7huv
SbvrHdrF30yM6GeMJx8OG0Y+scjAtPll/jf29vGnm4ohF9tp2DHRmpfzVLp6Fp1m
nKXKcVyqhXDgw2JjYTjkdkotCN/Qd/a0D3qdChs=
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:date:from:to:subject:message-id:references
:mime-version:content-type:in-reply-to; s=default; bh=E3/5LmDpAY
mEkw6IEvR2aaS15HM=; b=bQ9V8iv3fXZ0qtJdu1frmsd28G0tnBU4TR8LXAd6Ys
LCkpMm9edveIZQ3D2qNh7CX8DBeaou4kiH+OBKJJzaqhvewSOjt4nFtpBvkwvqjH
1BVUosQjmU24MDfWhXNIdpyIFKA5Syd3tTq1q163f1xBIQwSzFBPY9Mm/aunQcqQ
s=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail.spocom.com
Date: Wed, 1 Oct 2014 15:08:08 -0700
From: Gary Johnson <garyjohn AT spocom DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Direct/efficient way to chop off trailing \n
Message-ID: <20141001220807.GC10508@phoenix>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <loom DOT 20141001T235147-60 AT post DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <loom.20141001T235147-60@post.gmane.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
X-IsSubscribed: yes

On 2014-10-01, Paul.Domaskis wrote:
> Running bash in a Windows environment, I often find the need to
> generate a full Windows path to a file so that I can access the file
> from a Windows app.
> 
> If I use
> 
>    cygpath -aw TheFile > /dev/clipboard
> 
> I can paste into the Windows file-opener without browsing.  Also, I
> don't need to mouse around to highlight the result of cygpath.
> However, the clipboard always contains an invisible carriage return,
> which I have to remove by pressing backspacing.  This doesn't visibly
> change anything, but it does remove the trailing \n which chokes up
> Windows.
> 
> Since I hate manually deleting stuff that I can't see, the most
> efficient way around this seems to be:
> 
>    cygpath -aw | tr -d '\n' > /dev/clipboard
> 
> This is starting to get longer and longer.  It is comprising the whole
> goal of getting a sequence of operations that is so brief that one
> does not sigh at having to do it countless times.
> 
> Is there a more succinct way to get a clean path for a file from the
> bash shell into the Windows clipboard?

Define a function in your ~/.bashrc.

    winclip()
    {
        cygpath -aw "$@" | tr -d '\n' > /dev/clipboard
    }

Then just execute

    winclip TheFile

Regards,
Gary


--
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

- Raw text -


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