tab() # new tab from current dir
{
osascript -e "
tell application \"iTerm\"
tell the first terminal
launch session \"Default Session\"
tell the last session
write text \"cd $(pwd)\"
end tell
end tell
end tell"
}
Refactorings
No refactoring yet !
Marco Valtas
October 10, 2007, October 10, 2007 05:00, permalink
Macournoyer, I tried your function and it opens the server on my window then launches me to another tab. I prefer stay in my tab and launch the process in another tab. After some digging I came up with the code bellow, the difference in the command call is that you don't need use the ";".
So, what was: tab; script/server
Now should be: tab script/server
The only thing I could not solve is that iTerm changes the tab on a launch, so I had to bring it back with a "select session" call.
tab()
{
osascript -e "
tell application \"iTerm\"
tell the first terminal
set currentSession to current session
launch session \"Default Session\"
tell the last session
write text \"cd $(pwd)\"
write text \"$*\"
end tell
select currentSession
end tell
end tell"
}
macournoyer
October 10, 2007, October 10, 2007 12:25, permalink
great idea Marco, indeed it looked strange that is was launching in another tab, thx for the change!
Here's a small script I wrote to open a new tab in iTerm in the current directory. I place this in my .bash_profile and use it a lot to start Rails server and open a new tab to work in: tab; script/server
Know any better way of doing this ?
Btw, I'm also introducing a new language in here: Bash :) Hope you like it!
Also, I know the server is bloody slow, sorry for that. I'm migrating to a new and absurdly fast server at the moment. Hang on!