| delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| Date: | Fri, 13 Jan 2006 14:02:40 -0500 |
| From: | Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: cd to directory in paste buffer : shell function |
| Message-ID: | <20060113190240.GA4791@trixie.casa.cgf.cx> |
| Reply-To: | cygwin AT cygwin DOT com |
| References: | <rfqfs1pkamechtg6btjim15bkrt2l6miq5 AT 4ax DOT com> <Pine DOT GSO DOT 4 DOT 63 DOT 0601131349010 DOT 27020 AT access1 DOT cims DOT nyu DOT edu> |
| Mime-Version: | 1.0 |
| In-Reply-To: | <Pine.GSO.4.63.0601131349010.27020@access1.cims.nyu.edu> |
| User-Agent: | Mutt/1.5.11 |
| 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 |
On Fri, Jan 13, 2006 at 01:51:11PM -0500, Igor Peshansky wrote:
>On Fri, 13 Jan 2006, zzapper wrote:
>
>> Hi,
>>
>> 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)
>> }
>>
>> I can already see a few improvements, and it would also be nice to have
>> a check that paste buffer actually contains a path
>
>How about simply
>
>cd $(cygpath -f - < /dev/clipboard)
>
>? Or, in a more robust form,
>
>DIR="$(cygpath -f - < /dev/clipboard)"
>[ -d "$DIR" ] && cd "$DIR"
Or, even:
cdclip() {
cd "$(cygpath -f - < /dev/clipboard)" 2>/dev/null || :
}
Since apparently it's ok to have nothing happen when the clipboard
doesn't hold a directory.
cgf
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |