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@gmail.com>
To: cygwin@cygwin.com
Subject: Re: cd to directory in paste buffer : shell function
In-Reply-To: <rfqfs1pkamechtg6btjim15bkrt2l6miq5@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Disposition: inline
References: <rfqfs1pkamechtg6btjim15bkrt2l6miq5@4ax.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k0DISrEN016745

On 1/13/06, zzapper <david@tvis.co.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/


