Skip to content


iTerm Tricks

Marc Liyanage posted a script to open a new Terminal window in a specified directory or run a specified command.

What it does is open up a new Terminal window and execute the arguments as command in that new window. When no arguments are given, it opens the new window in the current directory, which means it acts like a “clone” operation for the frontmost window. This is useful if you’re in some deeply nested directory and you need a second window right there. This way you don’t have to copy/paste or type the directory path.

I modified the script slightly to interface with iTerm, opening a new default session instead of a new window.

Download the file, place somewhere in your path, and make sure its executable.

Examples:
Open a second iTerm session in the current directory.

term

Open a second iTerm session in my home directory.

term ~

Open a second iTerm session and start editing my .bashrc file.

term vi ~/.bashrc

Open a second iTerm session in the current directory and start editing filename.

term vi <em>filename</em>

Open a second iTerm session in the current directory (presumably /var/log/httpd) and start following the error_log file using tail.

term tail -f error_log

If this information and script is useful to you, please consider buying me a beer.

Popularity: 45% [?]

Posted in Apple / Mac, SysAdmin.


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. damonparker.org linked to this post on 9/20/2005

    iTerm Here Applescript Update

    Last week I posted a combination shell script, Applescript to open a new iTerm session in the local directory or a specified directory.
    Version 1.2 is available for download now.
    The Applescript was fixed so the new session alwasy opens in the cur…

  2. eFPe’s blog » Blog Archive » Linkz linked to this post on 2/26/2009

    [...] iTerm Tricks +1 [...]



Some HTML is OK

or, reply to this post via trackback.