Note: This page is here for historical reasons. Nowadays, most people have a computer with many gigabytes of memory. If you do, don't waste your time with Cygwin but install VirtualBox and Linux.
setup.exe
program from http://cygwin.com. Choose all default
options.Now issue the command
ln -s /cygdrive/c/Users/yourname/Downloads downloads
In the path name for the download directory, replace c:
with /cygdrive/c
and all backslashes (\) with forward slashes
(/).
As you type each path segment, type the first few characters, then the Tab key. That triggers autocompletion, which makes it easier to type the correct path name.
Type
ls downloads
Do you see the files in your browser's download directory, such as
setup.exe
? If not, type rm downloads
and try the
ln -s
command again.
Close the window. You now have a basic Cygwin setup.
setup.exe
program from http://cygwin.com. Choose all default
options until you get to the screen with title “Select
Packages”.
In the search box, type wget
. As you type the letters, the
box below shows fewer items. By the time that you type the letter
t
, only a couple are left. Click to expand any + icons until
you see a package with name wget. Click once onto the word Skip.
A version number will appear.
Now click Next and wait until the installation wizard finishes.
wget https://rawgit.com/transcode-open/apt-cyg/master/apt-cyg chmod +x apt-cyg mv apt-cyg /usr/local/bin apt-cyg install unzip
Note: If your user account has administrator privileges already, you can ignore all the “as administrator” instructions, and just run everything as yourself.
unzip downloads/emacs-xy.z-bin-i386.zip chmod +x emacs-*/bin/*.exe
Here xy.z is the Emacs version number of your download.
emacs-*/bin/emacs &
In the Emacs menu, select Options -> C-x/C-c/C-v Cut and Paste (CUA) and Options->Save Options. That changes the cut/copy/paste commands to the familiar Ctrl-X/Ctrl-C/Ctrl-V.
Now select File -> Open File... from the menu and select the file
named .emacs
. Note the period (.) before the filename.
If there is no such file, hit the following key combination instead:
[Control-X][Control-F]~/.emacs[Enter]
That is, hold down Control and X, let go of X but not of Control, type
F, let go of both, then type the eight characters ~/.emacs
and
then hit the Enter key. (If you already have a ~/
after
hitting [Control-X][Control-F], you can just enter the six characters
.emacs
and then Enter.)
At the end, add the following line:
(prefer-coding-system 'utf-8-unix)
Just paste it in with Ctrl+V.
Select Emacs-Lisp -> Evaluate Buffer from the menu. Then Select File -> Save.
Now select File -> Visit New File... from the menu and type in
.bash_profile
into the file dialog. (If the file exists, just
select it.) Note the period (.) before the filename.
Add the following lines:
export PS1='\w\$ ' export EMACS_HOME=~/emacs-xy.z export PATH=$PATH:$EMACS_HOME/bin
Again, xy.z is the Emacs version number. Paste in the commands and fix up the xy.z
Save the file and close the shell. From now on, you can simply start Emacs with
emacs filename &
emacs .bash_profile &
Add the following environment variable at the bottom of the file, before
the export PATH
statement:
export JAVA_HOME=/cygdrive/c/Program\ Files/Java/jdkversion/
where you should replace version with the version of your Java
installation. Make sure to put a \
before each space in the
path name. Then add $JAVA_HOME/bin
to the path, like this:
export PATH=$PATH:$EMACS_HOME/bin:$JAVA_HOME/bin
Save the file.
source .bash_profile javac -version
That's javac
, not java
.
If you get the correct version number, you are done.
tar xvfz downloads/scala-version.tgz
emacs .bash_profile
Add the following environment variable at the end of the file, before
the export PATH
statement:
export SCALA_HOME=~/scala-version
where version
is the Scala version.
Add $SCALA_HOME/bin
to the PATH.
export PATH=$PATH:$EMACS_HOME/bin:$JAVA_HOME/bin:$SCALA_HOME/bin
Save the file.
scala
You should get a shell prompt. Type
6*7
and hit Enter. Type Ctrl+D after you see the answer.
cd scala-version/misc/scala-tool-support/emacs apt-cyg install make make
In Emacs, load ~/.emacs
and add the following at the
end:
(add-to-list 'load-path "/home/yourname/scala-version/misc/scala-tool-support/emacs") (require 'scala-mode-auto)
apt-cyg install openssh mercurial
Close the shell.
emacs ~/.hgrc &
Put these lines into the file and save it.
[ui] username=Your name <username@mailserver.com> merge=internal:merge
Of course, use your actual name and email address.
ls ~/.ssh
If you get a directory listing showing (among others) a file
id_rsa.pub
, then skip this step. Otherwise, run
ssh-keygen -t rsa -C "Your name <username@mailserver.com>"
(of course, replacing Your name
with your name and
username@mailserver.com
with your email address). Accept the
default for the file name. When prompted for a passphrase, you can enter a
passphrase, which is more secure, but you have to enter it whenever you use
the key. Or just hit Enter to skip this.
Do not change the name of the key pair that is being generated.
It should be id_rsa
and id_rsa.pub
.
cat ~/.ssh/id_rsa.pub
Copy the text (starting with ssh-rsa
and ending with
Your name <username@mailserver.com>
and submit it to
your instructor or lab administrator. This key is needed to allow you
access to the Mercurial server.
Do not give out the private key (id_rsa
).
apt-cyg install ruby crypt
irb
You should get a shell prompt. Type
6*7
and hit Enter. Type Ctrl+D after you see the answer.
apt-cyg install make gcc4 sqlite3 libsqlite3_0 libsqlite3-devel
Still as administrator, run
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz tar xvfz rubygems-1.8.10.tgz cd rubygems-1.8.10 ruby setup.rb cd .. rm rubygems-1.8.10.tgz rm -rf rubygems-1.8.10
gem install rails sqlite3-ruby
rails new firstapp cd firstapp rails server
Point your browser to http://localhost:3000. If you get the Rails greeting screen, the installation was successful.
c:\somedir\somefile.ext
in Windows is
/cygdrive/c/somedir/somefile.ext
in Cygwin~
is
c:\cygwin\home\username
in Windows. Therefore,
somedir/somefile.ext
in Cygwin is
c:\cygwin\home\username\somedir\somefile.ext
.
Practice the correspondence by running ls somedir
or
ls /cygdrive/c/somedir
in Cygwin and looking at the same
directory in Windows Explorer.
Program\ Files
), escape it with a
\
.javac
compiler on Windows will not know
anything about /cygdrive/c
. Thus, it is
javac c:/somedir/SomeClass.java
(usually, forward slashes work in Windows—it's always worth trying) or
javac c:\\somedir\\SomeClass.java
Of course, Cygwin commands (such as rm
) don't know anything
about Windows-style filenames.
rm /cygdrive/c/somedir/SomeClass.class
Always ask yourself whether the command you are using has been written for Cygwin or for Windows.
java -cp .\;archive.jar some.package.SomeClass
.bash_profile
), it adds DOS style line endings (i.e.
\r\n
instead of \n
). That will confuse bash and
other Cygwin programs. If it happened to you, you can fix the file by
running
dos2unix filename
Inside Emacs, you can turn DOS style line endings into Unix style ones by running
C-x RET f unix RET
That is, Ctrl-X followed by the Enter key, the letter f, the four letters u n i x and another Enter. Once a file has Unix style line endings, Emacs will keep it so.
In Cygwin, Emacs shell mode is a DOS shell. That's no good. To fix that,
open the ~/.emacs
file. Add this mumbo-jumbo
(everything in the gray box). Quit and restart Emacs.
Type M-x shell
(that is, Alt+X followed by the letters
shell
and the Enter key). Voila, a Cygwin shell inside Emacs.
.emacs
file. For example, to add Emacs support to
Scala, add the following:
(add-to-list 'load-path "/path/to/scala/misc/scala-tool-support/emacs") (require 'scala-mode-auto)
Turn it on, then select all text in a Scala file and hit Tab to see auto-indenting.
apt-cyg
and gem
as
an administrator. When you are done installing software, close the shell
and launch another shell as a regular user.~/.inputrc
containing
# Makes PgUp, PgDn search history "\e[5~": history-search-backward "\e[6~": history-search-forward
Then you can type the first few letters of a command that you typed
previously, followed by the Page Up key. For example, javac
followed by Page Up is the last invocation of javac
. Hit Page
Up again to get the next one. Once you have one that is close to what you
want, edit it and hit Enter.
PATH
is consumed by Cygwin, so it uses
/cygdrive/c
. For example,
export PATH=$PATH:/cygdrive/c/ant/bin
What about a variable such as ANT_HOME
? Is it consumed by a
Windows executable or by a bash shell script? As it happens,
ant
is a shell script, so you use
export ANT_HOME=/cygdrive/c/ant
On the other hand, the CLASSPATH
is consumed by
javac
and java
, which are Windows executables.
They require Windows path names.
What if a variable is consumed both by a bash script and a Windows program? See the next two entries.
cygpath
command:
cygpath -w ~/somedir/somefile.ext
returns the Windows equivalent of a Unix path, and
cygpath c:\\somedir\\somefile.ext
returns the Cygwin equivalent of a Windows path.
Add the --path
option to convert paths (i.e., convert
between colons and semicolons).
# detect Cygwin cygwin=false; case "`uname`" in CYGWIN*) cygwin=true; esac
Then use cygpath
as needed:
if $cygwin; then SOMEVAR=`cygpath --path -w $SOMEVAR` fi
cygcheck
, such as
cygcheck ruby
or cygcheck /path/to/libfoo.so
.