Sunday, October 19, 2008

BASH IDE plugin for GVIM

http://www.linux.com/feature/114359


Download location of plugin:
http://www.vim.org/scripts/script.php?script_id=365


Or just execute the script given below to download and install the IDE.
(Script "unit" tested on Debian & OpenSUSE but should work out of the box on any other NIX flavor .)


Couldn't test this script on FreeBSD.
(as couldn't find "gvim" port under ftp://ftp.freebsd.org/pub/FreeBSD/ports)


#!/bin/bash
#===============================================================================
#
# FILE: gvim_bash_ide.sh
#
# USAGE: ./gvim_bash_ide.sh OR sh gvim_bash_ide.sh
#
# DESCRIPTION: The scripts downloads the bash ide plugin for gvim, extracts it & copies it under ~/.vim
#
# OPTIONS: ---
# REQUIREMENTS: gvim
# BUGS: ---
# NOTES: The script assumes gvim installed. Revision 1 of this file was tested on Debian 4.0 R2 & OpenSUSE 10.3.
#
# AUTHOR: Parag Kalra, paragkalra@gmail.com
# COMPANY: As of now (19-Oct-08) Persistent Systems LTD
# VERSION: 1.0
# CREATED: Sunday 19 October 2008 09:40:49 IST IST
# REVISION: 1
#===============================================================================

SRCID=9304

if [ -f /etc/debian_version ]
then
echo -e "\nSeems as if you are using Debian. Please make sure that gvim is installed. It comes packed with DVD ... \n"
elif [ -f /etc/SuSE-release ]
then
echo -e "\nSeems as if you are OpenSUSE or may be SLES. Please make sure that gvim is installed. It comes packed with DVD ...\n"
elif [ -f /etc/redhat-release ]
then
echo -e "\nSeems as if you are using Redhat or Fedora. Please make sure that gvim is installed. \n"
else
echo -e "\nPlease make sure that gvim is installed before adding bash ide plugin ... \n"
fi

if [ -d ~/.vim ]
then
echo -e "Directory ~/.vim already exists ... \n"
else
echo -e "Creating vim directory under user's home directory ... \n"
mkdir ~/.vim
echo -e "Navigating into ~/.vim \n"
cd ~/.vim
fi

echo -e "Downloading bash ide plugin for gvim from www.vim.org ... \n"
wget --verbose -P~/.vim http://www.vim.org/scripts/download_script.php?src_id=$SRCID -O bash-support.zip

#As of now this script downloads latest bash ide plugin. To download the latest plugin:
# 1. get the latest "src_id" from http://www.vim.org/scripts/script.php?script_id=365
# 2. and change the the "SRCID"

echo -e "Navigating into ~/.vim \n"
cd ~/.vim

echo -e "Unzipping bash ide plugin for gvim ... \n"
unzip bash-support.zip

echo -e "\nDeleting unused files ... \n"
rm -rf bash-support.zip

if [ -f ~/.vim/plugin/bash-support.vim ]
then
echo -e "Seems as if all went good. Open gvim and check the bash ide plugin ... \n"
else
echo -e "Something got screwed. Figure it out yourself ... \n"
fi


Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com

Saturday, October 11, 2008

Shell Script to show disk space, logged in users and memory usage.

#!/usr/bin/sh
#Author: Parag Kalra
#Date: 11th October, 2008

function menu {

clear
echo
echo -e "\t\t\tSys Admin Menu\n"
echo -e "\t1. Display disk space"
echo -e "\t2. Display logged on users"
echo -e "\t3. Display memory usage"
echo -e "\t0. Exit menu\n\n"
echo -en "\t\tEnter option: "
read -n 1 option

}

function diskspace {
clear
df -k
}

function users {
clear
who
}

function memusage {
clear
cat /proc/meminfo
}

while [ 1 ]
do
clear
menu

case $option in
0)
echo
break;;
1)
diskspace;;
2)
users;;
3)
memusage;;
*)
echo "Wrong Option"
esac

echo "Hit any key to continu!"
read -n 1 line
done


Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com