This is the mail archive of the
mailing list for the Cygwin project.
Re: cd to directory in paste buffer : shell function
On Fri, Jan 13, 2006 at 01:51:11PM -0500, Igor Peshansky wrote:
>On Fri, 13 Jan 2006, zzapper wrote:
>> I often want to cd to a (DOS) path that I've copied from some Windows
>> 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
>> 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"
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.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html