Last active
January 1, 2016 05:09
-
-
Save halilim/8096527 to your computer and use it in GitHub Desktop.
Gnome Terminals for Rails 3.2 and 4 - Modified from http://snipplr.com/view.php?codeview&id=32227
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Rails Terminals for Rails 3.2/4 and Gnome | |
# A simple script that opens a Gnome terminal with titled tabs: | |
# 1. Rails Server | |
# 2. Spork | |
# 3. bash | |
# and opens the app in: | |
# 1. Sublime Text | |
# 2. Browser | |
# USAGE: railsterminal working_dir | |
# | |
# Server and Spork terminals are kept around after Ctrl+C | |
# so that you can restart them. | |
# | |
# Lifted from http://snipplr.com/view.php?codeview&id=32227 | |
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 " | |
tab1="--tab -e";tab2="-t" | |
server_e="bash -c 'rails server && $SHELL'";server_t="Server" | |
spork_e="bash -c 'spork && $SHELL'";spork_t="Spork" | |
terminal_e=$SHELL;terminal_t="Terminal" | |
subl_e="subl $dir";subl_t="Sublime Text" | |
echo $command $tab1 "$server_e" $tab2 $server_t \ | |
$tab1 "$spork_e" $tab2 $spork_t \ | |
$tab1 "$subl_e" $tab2 $subl_t \ | |
$tab1 "$terminal_e" $tab2 $terminal_t | |
nohup xdg-open "http://localhost.dev:3000" > /dev/null 2>&1 & | |
$command $tab1 "$server_e" $tab2 $server_t \ | |
$tab1 "$spork_e" $tab2 $spork_t \ | |
$tab1 "$subl_e" $tab2 $subl_t \ | |
$tab1 "$terminal_e" $tab2 $terminal_t | |
# exit | |
else | |
echo "Please specify a working directory as the argument" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment