Monday, September 13, 2010

How to Install VoraX on Cygwin

I'm coming back with the promised post about how to install VoraX on Cygwin. So, let's begin!

First of all, you obviously need Cygwin. You may download it from here. From the looong list of available cygwin packages I recommend to install the following ones (there's a search text field on top):
  • gcc
  • make
  • bzip2
  • ncurses-devel
  • openssl-devel
  • ruby-1.8.7
  • wget
  • w3m
  • mintty
  • screen
Accept all dependencies cygwin installer suggests and start the installation process. If you'll need any additional packages you may opt to install them later.

Next, go ahead and launch cygwin from your desktop. If you don't like the command window terminal get rid of it and start using mintty. Change the C:\cygwin\cygwin.bat as shown below:

@echo off
C:
chdir C:\cygwin\bin
set CYGWIN=nodosfilewarning
start mintty -e /bin/bash --login -i

Start your new terminal and then customize it to suit to your preferences. You have an "Options" menu item available. I always find myself customizing:
  • foreground/background colors. I like black on white instead of the default opposite
  • block cursor
  • set Consolas 9 font. (if you don't have this font package you may download it from here).
  • right click action: Paste
  • TERM at startup: xterm
  • Scrollbar: none
  • uncheck "Ask for exit confirmation".
Now, it's time to compile vim with ruby support:

1. download vim 7.3 package:

cd /tmp
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2

2. uncompress the downloaded archive:

tar -xjf vim-7.3.tar.bz2

3. compile vim with ruby support:

cd vim73/
./configure --enable-rubyinterp --with-features=huge
make
make install

4. install rubygems utility:

cd /tmp
wget http://rubyforge.org/frs/download.php/70697/rubygems-1.3.7.zip
unzip rubygems-1.3.7.zip
cd rubygems-1.3.7
ruby setup.rb

5. install antlr3 gem:

gem install antlr3 -r

6. customize vim via .vimrc and install all your favorite vim plugins including of course VoraX. If you already have a _vimfiles directory in your $HOME then just copy it in your new cygwin home and change the name to .vim. Sqlplus should still be in your cygwin PATH.

Congrats! You have (at least I hope to) VoraX running on top of your Cygwin environment. So, you have the unix shell on your finger tips with all the useful tools you are so used to use: ssh, gnu screen, w3m etc.

However, I think is worth to mention some problems you may have migrating VoraX to Cygwin and some possible workarounds.

Problem 1: Where's my nice colorschema?
The first thing you'll notice is that your nice colorscheme on your gvim doesn't look the same on the console version of vim under Cygwin. There is a simple solution provided by CSApprox plugin. This plugin should seamlessly convert colors from the gui-version to the proper terminal colors. However, in order to have this conversion automatically done, our vim should have been compiled with "gui" support. But, we still have a fallback solution. CSApprox provides a way of creating a snapshot of your current colors into a new colorschema file. So, open your gvim windows version (which I suppose will open with your favorite colorschema) and use :CSApproxSnapshot [mycolors.vim]. This new colors file will be suitable for your terminal version of vim. If you like earendel colors I already have a converted schema. You may get it from here.

Problem 2: The title of mintty terminal doesn't change when a new VoraX connection is done.

This has nothing to do with mintty. You need to put this in your .vimrc:

set title

Problem 3: Under GNU Screen, colors are different and the title is not properly updated.

You may try the following .screenrc configuration:
# no annoying audible bell, please
vbell on

# detach on hangup
autodetach on

# don't display the copyright page
startup_message off

# generous scrollback
defscrollback 1000

# xterm for all new sessions
term xterm

# special xterm hardstatus: use the window title.
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'

# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB=background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"

That's it! Below is my VoraX into a GNU Screen session:


At the bottom of the VoraX window is a man page just to prove that we are under GNU Screen. And yes, it's on a Windows XP system. I think Oracle geeks may be happy on Windows too. :)

4 comments:

Andy said...

256-color support shouldn't need any termcap hacks actually. Instead, setting mintty's "TERM at startup" to xterm-256color and screen's to screen-256color (with 'term screen-256color' in .screenrc) should do the trick. I wouldn't recommend setting screen's TERM to xterm, because screen's control sequences aren't necessarily xterm-compatible.

Alexandru Tică said...

Hi Andy,

Thanks for clarifying this up! However, my choice for xterm was in connection with the title of mintty. If I open vim in a plain mintty console the title is updated accordingly, but doing the same under GNU screen doesn't update the title at all. Maybe a special screen setting is needed but I didn't manage to find any. Updating the title of the window is very important for VoraX so I opted for this workaround even I know, and you already pointed it out, is wrong.

Taral said...

Hi,

This seems to be nice tool. I want to give a try but not able to do so. I have installed everything.

So, what next. How to install plugin

I have installed ruby 1.9, vim 7.3 so what is next step for your pluging installation. Do, i need to unzip this files to /usr/share/vim/vim70.

Please, let me know how to install and what i have to do to run this (What commands) in vim.

Alexandru Tică said...

Ruby 1.8 please! You have to unzip those files under: $HOME/.vim (in unix/cygwin) or $HOME/vimfiles under Windows. See also: http://code.google.com/p/vorax/wiki/InstallationGuide