Skip to content

Instantly share code, notes, and snippets.

@roooodcastro
Created July 6, 2016 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roooodcastro/8dc9a65b8d9424f1f7c271f2935ba95f to your computer and use it in GitHub Desktop.
Save roooodcastro/8dc9a65b8d9424f1f7c271f2935ba95f to your computer and use it in GitHub Desktop.
Workspace setup scripts for Ruby on Rails
#!/bin/sh
type_command() {
xdotool type --delay 50 --clearmodifiers "$1"; xdotool key Return
}
new_tab() {
sleep 0.5
type_command "cd ~/workspace/$1"
sleep 0.5
type_command "$2"
sleep 0.5
}
# Get active gnome-terminal
WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
# Focus on it
xdotool windowfocus $WID
# Tab for Rails Server
new_tab $1 "rails s"
# Tab for Redis, Sidekiq or other
xdotool key ctrl+shift+t
new_tab $1 "la"
# Tab for Rails Console
xdotool key ctrl+shift+t
new_tab $1 "rails c"
# Tab for Git, RSpec and general playing around
xdotool key ctrl+shift+t
new_tab $1 "git status"
wmctrl -i -a $WID
#!/bin/bash
declare -A apps
apps=( \
[1]="app-1-path" \
[2]="app-2-path" \
[3]="app-3-path" \
)
dialog --keep-tite --menu "Select Application" 25 50 16 \
1 "Application 1" \
2 "Application 2" \
3 "Application 3" \
2>temp
app=""
# OK is pressed
if [ "$?" = "0" ]
then
_return=$(cat temp)
if [ "$_return" != "" ]
then
app=${apps[$_return]}
echo $sistema > last_boot_app
fi
else
echo "Automatic Startup Cancelled ):"
fi
rm -f temp
#!/bin/bash
notify-send 'Workspace Startup' 'Opening Console'
gnome-terminal &
sleep 15
notify-send 'Workspace Startup' 'Choosing Application'
# Get active gnome-terminal
WID=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| awk '{print $5}')
# Focus on it
xdotool windowfocus $WID
# Run system selection menu
xdotool type --delay 50 --clearmodifiers "~/.system_dialog.sh"
xdotool key Return
sleep 10
xdotool key Return
_app=$(cat last_boot_app)
echo $_app
notify-send 'Workspace Startup' "Configuring Console for \"$_sistema\""
~/.open_tabs.sh $_app &
sleep 30
notify-send 'Workspace Startup' 'Opening Google Chrome'
google-chrome &
sleep 30
notify-send 'Workspace Startup' 'Opening Rubymine'
/opt/rubymine/bin/rubymine.sh &
sleep 60
notify-send 'Workspace Startup' 'Startup Completed!'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment