Setting up VIM with better color scheme while working via dark console.

I spend a lot of time working in the console window as I manage multiple EC2 instances.
At work I use cygwin and at home I use gold old linux terminal. Depending on the configuration, vim color scheme might not be as terminal color friendly.
Look at the image below.
vim1

I could hardly read the comments on this shell script. Luckily vim does provides multiple color schemes to work with.
You can try different color scheme by running “:colorscheme” in vim.

:colorscheme delek

Instead of doing it every time, We can manage the default vim setting by creating a “.vimrc” file on the home directory.
Lets do that:

$ vi ~/.vimrc

Add following lines in the file


syntax on
colorscheme delek

I have selected have the syntax highlighting on and selected “delek” color scheme so its easier to read on my terminal.

vimrc

Now lets look at the same shell script:

vim2

And the output is much readable on the dark console.

You can select other color scheme depending on your preference. You can find the installed schemes at

/usr/share/vim/vim72/colors

Some of the default ones you may find are

blue.vim
darkblue.vim
default.vim
delek.vim
desert.vim
elflord.vim
evening.vim
koehler.vim
morning.vim
murphy.vim
pablo.vim
peachpuff.vim
README.txt
ron.vim
shine.vim
slate.vim
torte.vim
zellner.vim

You can download more online http://www.vimninjas.com/2012/08/26/10-vim-color-schemes-you-need-to-own/.

Advertisements

Ubuntu Window Placement Similar to Win7

With Ubuntu 11.04, It came with ‘Grid’ enabled under ‘Window Management’. This means, if you drag a ‘Window’ of an app to the right of the window it will stick to the right and left if you do left, taking half of the screen very similar to how Windows 7 has done. Drag from the mouse works fine however, the key combination is different than the Window. In this post I will talk about how to make it similar to how it works on Windows i.e. “Win + Right” key will stick the Window the right and “Win + Left” will stick the Window to the left.

To do this you need “CompizConfig Settings Manager” installed if you don’t have it already.
If you don’t then you can do so by running following command.

$ sudo apt-get install compizconfig-settings-manager

CompizConfig Settings Manager
Go to CompizConfig Settings Manager by going to “System>Preferences>CompizConfig Settings Manager”
Scroll down to the “Window Management”
Compiz Window

Grid
1. Click on the ‘Grid’ to manage the key bindings.
2. For this example lets work on the putting the window to the Left (to put on Right follow the same instructions except for picking the right key combinations)
a. Click on the key binding for action you want to edit, in this case right next to ‘Put Left’, (currently has ‘KP4’)
b. You will be prompted with a modal window, click on ‘Grab key cobination’

c. After you click on that button press the key that you want to bind the action with in our case lets do “Window Key + Left Arrow”
d. It should show ‘<Super>Left’ then click on ‘Ok’ button on the window to close it.
e. Now if you click on ‘Win’ Key + Left arrow then current window will take half of the screen and will be on the left side.

You can follow similar steps to do for pan the window right, maximize, minimize etc.

Mounting .disk file on Ubuntu

As mentioned in my earlier post, I recently upgraded my Ubuntu to 11.04. In my 10.10, I had created a virtual HDD called “home.disk” where I stored all my ‘home’ content. Now its time to recover some of that info.
This is how I am able to mount a ‘.disk’ file as a drive on ubuntu and be able to copy the content.

1. Creating a mount point
First of all you need to create a directory where you will be mounting your .disk file to

  $ sudo mkdir /media/homedisk

2. Mounting the disk file
I have my “home.disk” file in my external HDD which is mounted in my ubuntu under “/media/Elements/home.disk”
So, my command to mount it is as follows, (If you .disk file is elsewhere just point to that)

  $ sudo mount -o loop /media/Elements/home.disk /media/homedisk

There you have it!, now you should see an icon on your desktop called ‘homedisk’ and if you click in there, you should see the contents of the file!

Setting up Groovy and Grails on Ubuntu 11.04

After upgrading my Ubuntu since 8.04 to 10.10 as a regular system upgrade my system started becoming really slow. So, I decided to do a clean install of Ubuntu 11.04.
As I am going through this I wanted to document the process of setting up Ubuntu 11.04 with Groovy and Grails.(Note: I have Ubuntu 64 bit installed, there may be extra steps I may had to do compared to 32 bit.)

1. Installing JDK
As a first steps, we will have to install JDK.
Lets run the following command to install the JDK on the system

$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

2. Installing Eclipse
a. Let’s grab the latest version of eclipse from the eclipse.org website
http://www.eclipse.org/downloads/

b. I got the “Eclipse IDE for Java EE Developers” (64- bit version as my Ubuntu is 64 bit)

c. After you obtain the zip, simiply unzip the content to the home folder. This should result in structure like “/home/manijshrestha/eclipse”

3. Groovy Eclipse plug-in
You can follow the instructions in groovy website in
http://groovy.codehaus.org/Compiler+Switching+within+Groovy-Eclipse

a. go to “Help>Install New Software… ”
b. Put “http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/&#8221; and hit enter
c. Install “Groovy-Eclipse”, “Groovy Eclipse SDK” and “Extra Groovy Compilers”

4. Grails Install
For grails, spring source provides with STS plugin for eclipse, Lets install that,
For that, Similar to Groovy Install, lets install the STS plug-in. Lets follow the steps below

a. go to “Help>Install New Software… ”

b. Click on “Add” Button and put following URL
http://dist.springsource.com/release/TOOLS/update/e3.6
(you can give a name like “Spring STS” etc)

c. Click on “Add” Button again to add URL for dependencies:
http://dist.springsource.com/release/TOOLS/composite/e3.6
(you can give name like “Spring Dependencies”)

d. Back in the “Install New Software” window, choose to work with: ”SpringSource update site for Eclipse 3.6 Release”

e. Select ”SpringSource Tool Suite Grails Support” under the category ”Extensions / STS”

f. Press the Next button and follow the wizard to complete the installation. The installation might seem to be stuck at zero percent for a couple of minutes, just be patient. You will also get a warning that you are trying to install unsigned content which is normal in this case.

g. Re-start eclipse as prompted and you are DONE!
(you can verify the settings by going to File>New>Other – You should see “Groovy” and “Grails” listed…)

Note
These plug-ins are installed inside Eclipse so in the “Terminal” you may not see a result if you do “groovy -version” or “grails -version”.

I will post on how to manually install Groovy and Grails on Ubuntu in my next Post.
(References: http://blog.callistaenterprise.se/2011/01/13/setting-up-your-eclipse-environment-for-groovy-and-grails/)

Ubuntu updating system time

Today is the DST time, however, I found out that my Ubuntu did not update the time accordingly. (Thank god I checked my cell phone network time, else I would have missed my flight).
Here is how to update system time in ubuntu
$: sudo ntpdate pool.ntp.org
This will update the system time accordingly. you can use any time server you want just replace pool.ntp.org with the server you desire.

Adding New virtual HDD on Wubi

In one of my laptops, I have been using Ubuntu under Wubi. It is great as I get to use full blown Ubuntu and still can get access to Windows when needed. One of the limitation is though that virtual HDD assigned under Ubuntu can get full really quickly (specially with the system updates and other PPA updates). So, I am going to talk about how we can get pass it by creating a virtual HDD and attaching it to Ubuntu.

Here are the steps to create and attach the HDD.
Step 1: Creating a virtual HDD
Run following command to create a 20 GB hdd (I will use this hdd as my primary home directory)
$: /host/ubuntu/disks$ dd if=/dev/zero of=extra.disk bs=1MB count=20000 seek=1
NOTE: here i am calling it a “extra.disk”, you can name it anything you want.

Step 2: Formatting the virtual HDD to ext3
$: /host/ubuntu/disks$ mkfs.ext3 -F extra.disk
NOTE: make sure you use the right disk in our case its “extra.disk”

Step 3: Creating a backup
$: mv home home.backup
$: mkdir home
$: mount home
$: rsync -av –exclude=home.backup/.gvfs home.backup/* home

ref: https://wiki.ubuntu.com/WubiGuide#How%20do%20I%20resize%20the%20virtual%20disks?