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
Sunday, October 19, 2008
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
#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
Saturday, June 14, 2008
Shell-script to add comments and html tags in php files.
I am sometimes required to write PHP scripts and I find typing tags and comments quite boring. Look what I have done. I have written a fully automated script that will make you job very easy and you can easily place tags and comments into your php scripts.
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#!/bin/bash
#Author: Parag Kalra
#Date: 14th June, 2008
#Name: php-tags.sh
#Usage: ./php-tags.sh
#Purpose: To automatically add comments and html tags.
# BEGINNING
echo "Enter the name of the shell script: "
read SHNAME
echo "Enter the purpose of this shell script: "
read SHPURPOSE
export SHDATE #='$SHDATE'
export SHNAME #='$SHNAME'
export SHPURPOSE #='$SHPURPOSE'
touch $SHNAME
echo "html tag" >> $SHNAME
echo "head tag, title tag, title end tag, head end title>" >> $SHNAME
echo "body tag" >> $SHNAME
echo "php start tag" >> $SHNAME
echo "#!/bin/bash" >> $SHNAME
echo "#Author: Parag Kalra" >> $SHNAME
echo "#Date: $SHDATE" >> $SHNAME
echo "#Name: $SHNAME" >> $SHNAME
echo "#Usage: ./$SHNAME" >> $SHNAME
echo "#Purpose: $SHPURPOSE" >> $SHNAME
echo "php end tag" >> $SHNAME
echo "body end tag" >> $SHNAME
echo "html end tag" >> $SHNAME
#END OF SCRIPT
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#!/bin/bash
#Author: Parag Kalra
#Date: 14th June, 2008
#Name: php-tags.sh
#Usage: ./php-tags.sh
#Purpose: To automatically add comments and html tags.
# BEGINNING
echo "Enter the name of the shell script: "
read SHNAME
echo "Enter the purpose of this shell script: "
read SHPURPOSE
export SHDATE #='$SHDATE'
export SHNAME #='$SHNAME'
export SHPURPOSE #='$SHPURPOSE'
touch $SHNAME
echo "html tag" >> $SHNAME
echo "head tag, title tag, title end tag, head end title>" >> $SHNAME
echo "body tag" >> $SHNAME
echo "php start tag" >> $SHNAME
echo "#!/bin/bash" >> $SHNAME
echo "#Author: Parag Kalra" >> $SHNAME
echo "#Date: $SHDATE" >> $SHNAME
echo "#Name: $SHNAME" >> $SHNAME
echo "#Usage: ./$SHNAME" >> $SHNAME
echo "#Purpose: $SHPURPOSE" >> $SHNAME
echo "php end tag" >> $SHNAME
echo "body end tag" >> $SHNAME
echo "html end tag" >> $SHNAME
#END OF SCRIPT
Monday, June 2, 2008
Functions in Shell-Scripting => Part 1
#!/bin/bash
#Author: Parag Kalra
#Date: 3rd June, 2008
#Name: func1.sh
#Usage: ./func1.sh
#Purpose: To illustrate usage of functions in Shell Scripts.
JUST_A_SECOND=1
REPEATS=3
funky()
{
echo "This is a just funky function...not that exciting..."
}
fun()
{
echo "The real fun starts now."
i=0
sleep $JUST_A_SECOND
while [ $i -lt $REPEATS ]
do
echo "FUNCTIONS R FUN"
echo
let "i+=1"
done
}
funky
fun
The output of above script is:
This is a just funky function...not that exciting...
The real fun starts now.
FUNCTIONS R FUN
FUNCTIONS R FUN
FUNCTIONS R FUN
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#Author: Parag Kalra
#Date: 3rd June, 2008
#Name: func1.sh
#Usage: ./func1.sh
#Purpose: To illustrate usage of functions in Shell Scripts.
JUST_A_SECOND=1
REPEATS=3
funky()
{
echo "This is a just funky function...not that exciting..."
}
fun()
{
echo "The real fun starts now."
i=0
sleep $JUST_A_SECOND
while [ $i -lt $REPEATS ]
do
echo "FUNCTIONS R FUN"
echo
let "i+=1"
done
}
funky
fun
The output of above script is:
This is a just funky function...not that exciting...
The real fun starts now.
FUNCTIONS R FUN
FUNCTIONS R FUN
FUNCTIONS R FUN
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
Sunday, June 1, 2008
Concept of Sub-Shells - Part 2
Variables defined in a subshell are "local variables. Also variable operations inside a subshell, even to a GLOBAL variable do not affect the value of the variable outside the subshell! Kindly refer to the script given below:
#!/bin/bash
#Author: Parag Kalra
#Date: 1st June, 2008
#Name: glo-var-sub-shell.sh
#Usage: ./glo-var-sub-shell.sh
#Purpose: To illustrate concept of global variables within sub-shells
global_variable=
outer_num=12
echo "Outside Subshell"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num "
echo " "
(
echo "Inside Subshell"
inner_variable=26
let "outer_num+=1"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable "
echo " "
)
echo "Again Outside of Subshell"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable"
# END OF SCRIPT
The output of above script is:
Outside Subshell
global_variable=
outer_num=12
Inside Subshell
global_variable=
outer_num=13
inner_variable=26
Again Outside of Subshell
outer_num=12
inner_variable=
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
#!/bin/bash
#Author: Parag Kalra
#Date: 1st June, 2008
#Name: glo-var-sub-shell.sh
#Usage: ./glo-var-sub-shell.sh
#Purpose: To illustrate concept of global variables within sub-shells
global_variable=
outer_num=12
echo "Outside Subshell"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num "
echo " "
(
echo "Inside Subshell"
inner_variable=26
let "outer_num+=1"
echo "global_variable=$global_variable"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable "
echo " "
)
echo "Again Outside of Subshell"
echo "outer_num=$outer_num"
echo "inner_variable=$inner_variable"
# END OF SCRIPT
The output of above script is:
Outside Subshell
global_variable=
outer_num=12
Inside Subshell
global_variable=
outer_num=13
inner_variable=26
Again Outside of Subshell
outer_num=12
inner_variable=
Just go through it and let me know if you happen to come across any bug in it. eMail me at paragkalra@gmail.com
Friday, May 30, 2008
Concept of Sub-Shells - Part1
First & foremost to create sub-shells within a script you need to use round brackets "( )". Value assigned to outermost shell is always 0. As you move inside sub-shells their values keep on increasing by 1 as depicted in the example shown below:
#!/bin/bash
#Author: Parag Kalra
#Date: 31st May, 2008
#Name: subshell1.sh
#Usage: ./subshell1.sh
#Purpose: To illustrate values assigned to sub-shells
echo "We are outside the subshell."
echo "Subshell level OUTSIDE subshell = $BASH_SUBSHELL"
(
echo "We are inside first subshell."
echo "Subshell level INSIDE first subshell = $BASH_SUBSHELL"
(
echo "Inside second sub-shell"
echo "Subshell level INSIDE second subshell = $BASH_SUBSHELL"
(
echo "Inside third sub-shell"
echo "Subshell level INSIDE third subshell = $BASH_SUBSHELL"
)
)
)
echo "We are again outside all the subshells."
echo "Subshell level OUTSIDE subshell = $BASH_SUBSHELL"
#END OF SCRIPT
The output of above script is:
We are outside the subshell.
Subshell level OUTSIDE subshell = 0
We are inside first subshell.
Subshell level INSIDE first subshell = 1
Inside second sub-shell
Subshell level INSIDE second subshell = 2
Inside third sub-shell
Subshell level INSIDE third subshell = 3
We are again outside all the subshells.
Subshell level OUTSIDE subshell = 0
#!/bin/bash
#Author: Parag Kalra
#Date: 31st May, 2008
#Name: subshell1.sh
#Usage: ./subshell1.sh
#Purpose: To illustrate values assigned to sub-shells
echo "We are outside the subshell."
echo "Subshell level OUTSIDE subshell = $BASH_SUBSHELL"
(
echo "We are inside first subshell."
echo "Subshell level INSIDE first subshell = $BASH_SUBSHELL"
(
echo "Inside second sub-shell"
echo "Subshell level INSIDE second subshell = $BASH_SUBSHELL"
(
echo "Inside third sub-shell"
echo "Subshell level INSIDE third subshell = $BASH_SUBSHELL"
)
)
)
echo "We are again outside all the subshells."
echo "Subshell level OUTSIDE subshell = $BASH_SUBSHELL"
#END OF SCRIPT
The output of above script is:
We are outside the subshell.
Subshell level OUTSIDE subshell = 0
We are inside first subshell.
Subshell level INSIDE first subshell = 1
Inside second sub-shell
Subshell level INSIDE second subshell = 2
Inside third sub-shell
Subshell level INSIDE third subshell = 3
We are again outside all the subshells.
Subshell level OUTSIDE subshell = 0
Thursday, May 29, 2008
Shell-Script to add headers to another Shell-Script
I write Shell-Scripts day in day out. For each and every shell-script I need to place following headers at the beginning of it. For e.g. consider following header:
#!/bin/bash
#Author:
#Date:
#Name:
#Usage:
#Purpose:
I have prepared a shell-script to automatically add the above header to the newly created shell-script. Just go through it and let me know if you happen to come across any bug in it:
#!/bin/bash
#Author: Parag Kalra
#Date: 30th May, 2008
#Name: shell-script-header.sh
#Usage: ./shell-script-header.sh
#Purpose: To add headers to shell-scripts
echo "Enter the date: "
read SHDATE
echo "Enter the name of the shell script: "
read SHNAME
echo "Enter the purpose of this shell script: "
read SHPURPOSE
export SHDATE #='$SHDATE'
export SHNAME #='$SHNAME'
export SHPURPOSE #='$SHPURPOSE'
touch $SHNAME
echo "#!/bin/bash" >> $SHNAME
echo "#Author: Parag Kalra" >> $SHNAME
echo "#Date: $SHDATE" >> $SHNAME
echo "#Name: $SHNAME" >> $SHNAME
echo "#Usage: ./$SHNAME" >> $SHNAME
echo "#Purpose: $SHPURPOSE" >> $SHNAME
#END OF SCRIPT
#!/bin/bash
#Author:
#Date:
#Name:
#Usage:
#Purpose:
I have prepared a shell-script to automatically add the above header to the newly created shell-script. Just go through it and let me know if you happen to come across any bug in it:
#!/bin/bash
#Author: Parag Kalra
#Date: 30th May, 2008
#Name: shell-script-header.sh
#Usage: ./shell-script-header.sh
#Purpose: To add headers to shell-scripts
echo "Enter the date: "
read SHDATE
echo "Enter the name of the shell script: "
read SHNAME
echo "Enter the purpose of this shell script: "
read SHPURPOSE
export SHDATE #='$SHDATE'
export SHNAME #='$SHNAME'
export SHPURPOSE #='$SHPURPOSE'
touch $SHNAME
echo "#!/bin/bash" >> $SHNAME
echo "#Author: Parag Kalra" >> $SHNAME
echo "#Date: $SHDATE" >> $SHNAME
echo "#Name: $SHNAME" >> $SHNAME
echo "#Usage: ./$SHNAME" >> $SHNAME
echo "#Purpose: $SHPURPOSE" >> $SHNAME
#END OF SCRIPT
Subscribe to:
Comments (Atom)
