This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Direct/efficient way to chop off trailing \n


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]