Return to Snippet

Revision: 26133
at April 18, 2010 16:42 by draq


Initial Code
#!/bin/bash

# Rails Terminals for Rails 2.3.5 and Gnome
# A simple script that opens a Gnome terminal with titled tabs:
# 1. Server
# 2. Autospec
# 3. Vim with NERDTree
# 4. bash
# USAGE: railsterminal.sh working_dir

dir=$1	# The first argument is the path of the working directory.

if [ -z $dir ]; then
	echo "Please specify an argument!"
	exit
fi

# Check whether the executables exist and open the terminals
if [ -d $dir ]; then
	
	# If the argument is a relative path, then augment it with 
	# the current dir.
	if [ ${dir:0:1} != '~' -a ${dir:0:1} != '/' ]; then
		dir=`pwd`'/'$dir
	fi
	echo "Working directory: $dir"

	command="gnome-terminal --working-directory=$dir --geometry=112x30 "
	tab1="--tab -e";tab2="-t"
	if [ -x "$dir/script/server" ]; then
		server_e="bash -c 'script/server && bash'"
	else
		server_e='bash'
		echo "script/server not found."
	fi	
	if [ -x "$dir/script/autospec" ]; then
		autospec_e="script/autospec"
	else
		autospec_e='bash'
		echo "script/autospec not found."
	fi
	server_t="Server";autospec_t="Autospec"
	bash_e="bash";bash_t="Bash"
	vim_e="vi +NERDTree";vim_t="Vim"
	
	echo $command $tab1 "$server_e" $tab2 $server_t \
		 $tab1 "$autospec_e" $tab2 $autospec_t \
		 $tab1 "$vim_e" $tab2 $vim_t \
		 $tab1 "$bash_e" $tab2 $bash_t 

	$command $tab1 "$server_e" $tab2 $server_t \
		 $tab1 "$autospec_e" $tab2 $autospec_t \
		 $tab1 "$vim_e" $tab2 $vim_t \
		 $tab1 "$bash_e" $tab2 $bash_t 

else
	echo "Please specify a working directory as the argument"
fi

Initial URL


Initial Description


Initial Title
Gnome Terminals for Rails

Initial Tags
rails

Initial Language
Bash