This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: cd to directory in paste buffer : shell function
- From: Svend Sorensen <ssorensen at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 13 Jan 2006 10:28:45 -0800
- Subject: Re: cd to directory in paste buffer : shell function
- References: <rfqfs1pkamechtg6btjim15bkrt2l6miq5@4ax.com>
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/