delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/13/13:28:54

X-Spam-Check-By: sourceware.org
Message-ID: <7ff9c2a10601131028q66185044qb68ba0700b36fb21@mail.gmail.com>
Date: Fri, 13 Jan 2006 10:28:45 -0800
From: Svend Sorensen <ssorensen AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: cd to directory in paste buffer : shell function
In-Reply-To: <rfqfs1pkamechtg6btjim15bkrt2l6miq5@4ax.com>
MIME-Version: 1.0
References: <rfqfs1pkamechtg6btjim15bkrt2l6miq5 AT 4ax DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k0DISrEN016745

On 1/13/06, zzapper <david AT tvis DOT co DOT uk> wrote:
> I often want to cd to a (DOS) path that I've copied from some Windows App.
>
> The following function (put in one of your startup files .bashrc .profile etc)  saves a few clicks
> and is forward or backslash proof
>
> function cdp()
> {
> # cdp(aste)
> # description : Cd to path in paste buffer: convert from DOS if required
> # set -x
> getclip
> echo ''
> getclip|sed 's#\\#\/#g'|putclip
> cd $(getclip)
> }

The cygpath program will do the slash conversion for you:

cdclipboard()
{
        unixpath=`cygpath -f /dev/clipboard`;

        if [ -d "$unixpath" ]; then
                cd "$unixpath"
        fi
}

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