Created
April 3, 2018 12:27
-
-
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.
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
# 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