Skip to content

Instantly share code, notes, and snippets.

@diegommarino
Created April 3, 2018 12:27
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 diegommarino/2d7c0492e6c9d36d7b599bb606b4557e to your computer and use it in GitHub Desktop.
Save diegommarino/2d7c0492e6c9d36d7b599bb606b4557e to your computer and use it in GitHub Desktop.
Example of function function to create a custom session in iterm2 using applescript syntax.
# Add this function to create a custom session in iterm2 using applescript
iterm-custom-session () {
osascript -e 'tell application "iTerm"
(* set the project path. You can add a bash variable too for more felxibility *)
set projectPath to "your_project_path"
select first window
tell the current window
(* Split first session in two and enter in the project path *)
activate current session
tell the current session
write text "cd " & projectPath
split vertically with default profile
end tell
(* cd to rails directory and start console in the second session and aplit it horizontally *)
tell second session of current tab
write text "cd " & projectPath
write text "rails c"
split horizontally with default profile
end tell
(* Select the third session and track the log file *)
tell third session of current tab
write text "cd " & projectPath
write text "tail -f log/development.log"
end tell
(* Open a new tab and start a rails server for the project *)
set newTab to (create tab with default profile)
select last tab
tell the current session
write text "cd " & projectPath
write text "rails s;"
end tell
end tell
end tell'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment