Total Hit Counter

Friday, March 22, 2013

Play with VIM editor




  • To use mouse in vim editor copy and paste following line in to /etc/vim/vimrc file.Using mouse we can move cursor like we are moving in notepad.

set mouse=a             " Enable mouse usage (all modes)



  • To make variables and system functions colorful add folowing line in to  /etc/vim/vimrc file.
syntax on



  • By default in debian we opens a file in vim editor then vim is not saving our last position of the cursor.
      To enable that write following lines in to the /etc/vim/vimrc file.

if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif



Continue.......

Friday, March 8, 2013

Date command in linux

Hi Friends,

We can convert Unix timestamp to date and date to unix timestamp using date command .

Unix timestamp to date conversion.


root@SHANKAR:~# date -d @1285977600
Fri Oct  1 17:00:00 PDT 2010


Date to Unix timestamp conversion.

root@SHANKAR:~# date -d "2010-10-30" "+%s"
1288422000


Thursday, March 7, 2013

Rebuild your deb package by updating some files

#!/bin/bash

# script name: rebuild-deb.sh
# extracts/rebuilds a deb package
# Put your deb and the script in a new directory and run it from there


echo "This script extracts and rebuilds a deb package. "
echo "It should called from the directory containing the original deb and run as:"
echo "./rebuild-deb.sh"
echo
ls
echo
echo "1.   Extract deb?"
echo "2.   Make deb?"
echo "Enter <1/2> :"
read REPLY
echo

   if [ "$REPLY" = "1" ]; then
ls

DEB=$(ls *.deb 2>&1)
mkdir package
cd ./package
ar -x ../$DEB

   rm debian-binary
   tar xvzf data.tar.gz && rm data.tar.gz
   mkdir DEBIAN && cd DEBIAN
   tar xvzf ../control.tar.gz && rm ../control.tar.gz

   echo "Extracted to './package'"
   echo "Make your changes. Make sure to update control and md5sum files"   
   elif [ "$REPLY" = "2" ]; then

PACKAGE=$(cat 'package/DEBIAN/control'|grep Package|sed 's|Package: ||')
VERSION=$(cat 'package/DEBIAN/control'|grep Version|sed 's|Version: ||')
ARCH=$(cat 'package/DEBIAN/control'|grep Architecture|sed 's|Architecture: ||')
fakeroot dpkg-deb -b package $PACKAGE\_$VERSION\_$ARCH.deb
   
   echo "Done"
fi