# Spawning iTerm Windows

DevFeed: [Spawning iTerm Windows](<https://devfeed.tech/articles/spawning-iterm-windows-25379.md>)

Original publisher: [Read original article](<https://smileykeith.com/2013/01/03/spawn-iterm/>)

Author: Keith Smiley

Published: 2013-01-03T20:34:00Z

Content type: tutorial

Language: en

Sources: [Keith Smiley](<https://devfeed.tech/sources/keith-smiley.md>)

Topics: [Terminal](<https://devfeed.tech/topics/terminal.md>), [Zsh](<https://devfeed.tech/topics/zsh.md>), [Code](<https://devfeed.tech/topics/code.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [function](<https://devfeed.tech/tags/function.md>), [run](<https://devfeed.tech/tags/run.md>), [terminal](<https://devfeed.tech/tags/terminal.md>)

## AI overview

The article explains how to create a shell command that opens a new iTerm window in the current working directory. It uses an AppleScript invoked through osascript and exposes the script through a zsh function named spawn.

## Source excerpt

I've recently been searching around for a good way to 'spawn' an iTerm window (no I don't use tabs in iTerm), at the pwd in my current iTerm window. I couldn't find any good way to do it so I jumped in to AppleScript Editor and made something happen. on run argv tell application "iTerm" set t to make new terminal tell t activate current session launch session "Default Session" tell the last session write text "cd \"" & item 1 of argv & "\"; clear; pwd" end tell end tell end tell end run I then added it to my zsh aliases with: function spawn { osascript ~/Dropbox/Code/Applescript/Spawn/SpawniTerm.applescript $PWD } Now I can call spawn from any iTerm or Terminal window to open a new iTerm session wherever I called it from.