Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert current cygwin directory to windows format

To display current directory I am using $pwd which is working fine in Cygwin.

This document is explaining how to convert cygwin directory to windows format. But why $cygpath -w pwd and $cygpath -w $pwd is not working?

It is what I am getting in that case:

enter image description here

like image 830
sreginogemoh Avatar asked Dec 24 '22 11:12

sreginogemoh


2 Answers

try any of these versions:

cygpath -w "$(pwd)"
cygpath -w "$PWD"
cygpath -w "`pwd`"
like image 51
anishsane Avatar answered Feb 08 '23 17:02

anishsane


I didn't want to remember cygpath - so i created a wrapper around pwd and added to my .bashrc

pwd()
{
    if [[ $1 == "-W" ]] ; then 
        cygpath -aw .; 
    else 
        wpwd="-W, --winpath\t  Gives you actual Windoze path"
        err_msg=$(/usr/bin/pwd $* 2>&1);
        let "v = $?"
        if [ $v -eq 1 ] ;  then # have error
            echo "${err_msg}" | sed 's/.*pwd --help.*//' ;
            /usr/bin/pwd --help | sed "s|\(.*  -L, --logi.*\)|  $wpwd\n\1|" 
        else 
            echo "${err_msg}"
        fi
    fi
}

`

like image 21
ProfessionalHack Avatar answered Feb 08 '23 15:02

ProfessionalHack