395
votes

I'm trying to install PyQt4 so I can mess around with it. The installation guide said I had to install Sip. The last step to installing Sip is to use the make install command. Windows doesn't have that, so I looked it up and everything I saw said to install Cygwin. So I did. But...sip is in C:\Python31\sip.

Can I run this from the Cygwin command? If so, how would I do that?

Or can I run this from the normal windows command prompt? If so, how would I go about that?

13

13 Answers

779
votes
202
votes

I'll add something that helps me out a lot with cygwin. Whenever setting up a new system, I always do this

ln -s /cygdrive/c /c

This creates a symbolic link to /cygdrive/c with a new file called /c (in the home directory)

Then you can do this in your shell

cd /c/Foo
cd /c/

Very handy.

139
votes

cd c: is supported now in cygwin

51
votes

You already accepted an answer, but I just thought I'd mention that the following also works in Cygwin:

cd "C:\Foo"

I think the cd /cygdrive/c method is better, but sometimes it's useful to know that you can do this too.

8
votes

You can just use

cd C:/Users/../..
6
votes

As you'll probably want to do this often, add aliases into your .bashrc file, like:

alias cdc='cd /cygdrive/c'
alias cdp='cd /cygdrive/p'

Then you can just type on the command line:

cdc
3
votes

Define a variable in .bashrc :

export C=/cygdrive/c

then you can use

cd $C/

and the tab autocompletes correctly (please include the / at the end)

2
votes

On a related note, you may also like:

shopt -s autocd

This allows you to cd a dir by just typing in the dir

[user@host ~]$ /cygdrive/d
cd /cygdrive/d
[user@host /cygdrive/d]$ 

To make is persistent you should add it to your ~/.bashrc

1
votes

you can try this

/cygdrive/c/directoryname
1
votes

The one I like is: cd C:

To have linux like feel then do:

ln -s /cygdrive/c/folder ~/folder

and use this like: ~/folder/..

0
votes

Create a file named "overrideBashCdForWindowsPaths" in your HOME folder. Paste the following lines into that file and save it:

#!/bin/bash

function cd() {
    CD_PATH="$(history | tail -1 | sed -e "s,.*${FUNCNAME[0]}\s*,,g")"

    if [ -z "${CD_PATH}" -o "${CD_PATH}" = "~" ]; then
        CD_PATH="${HOME}"
    fi

    builtin cd "$(cygpath "$CD_PATH")"
}

Next, type the following command in a terminal, while you are in your HOME folder:

echo ". overrideBashCdForWindowsPaths" >> .bashrc

Close your terminal and open a new one. You can now easily change into that Windows folder by simply typing

cd C:\Python31\sip

The script reads the last command, extracts the path and passes it to Cygwin's path-conversion tool. By naming the function "cd" we sort of 'override' Bash's builtin "cd" and delegate the actual call to it in the very last line.

0
votes

Something that is worth mentioning here is that Cygwin's cygpath, still does not handle spaced Windows paths properly, especially in Bash scripts running under Cygwin. The trick is to understand how Cygwin interprets quotes in Bash scripts.

The following does not work:

#!/bin/bash
TBDIR="/cygdrive/c/Program\ Files\ \(x86\)/MyDir/"

if [ -d "${TBDIR}" ]; then 
    echo "Found MyDir directory at: ${TBDIR}"
    cd "$TBDIR"
else 
    echo "MyDir program directory not found!"
    echo "Wrong DIR path: ${TBDIR}"
    exit 1
fi

But this does work:

#!/bin/bash
# Cygwin-ism: No quotes!
TBDIR=/cygdrive/c/Program\ Files\ \(x86\)/MyDir/

if [ -d "${TBDIR}" ]; then 
...

As far as I know, there is currently no known workaround using cygpath, that can properly handle spaces in the bash scripting context but you can use quotes in your scripts.

0
votes

$cd C:\

> (Press enter when you see this line)

You are now in the C drive.