Skip to content

Instantly share code, notes, and snippets.

@RPing
Last active December 10, 2016 06:44
Show Gist options
  • Save RPing/a93c7c5629663ca28542bd5b09c59341 to your computer and use it in GitHub Desktop.
Save RPing/a93c7c5629663ca28542bd5b09c59341 to your computer and use it in GitHub Desktop.

Revisions

  1. RPing renamed this gist Dec 10, 2016. 1 changed file with 12 additions and 9 deletions.
    21 changes: 12 additions & 9 deletions Open in iTerm2-nightly → Open iTerm2 in Finder folder
    Original file line number Diff line number Diff line change
    @@ -9,22 +9,25 @@ on run {input, parameters}
    set filetype to (kind of (info for my_file))
    -- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
    -- http://stackoverflow.com/a/6881524/640517
    if filetype is "Folder" or filetype is "Volume" then
    set dir_path to quoted form of (POSIX path of my_file)
    else
    set dir_path to quoted form of (POSIX path of (container of my_file as string))
    end if
    set dir_path to quoted form of (POSIX path of my_file)
    end tell
    CD_to(dir_path)
    end run

    on CD_to(theDir)
    tell application "iTerm"
    activate
    set go_dir to "cd " & theDir
    set newWindow to (create window with default profile)
    tell current session of first window
    write text go_dir

    tell current window
    set go_dir to "cd " & theDir
    set newTab to (create tab with default profile)
    tell newTab
    select
    tell current session of newTab
    write text go_dir
    end tell
    end tell
    end tell

    end tell
    end CD_to
  2. Gascar ShunT revised this gist Nov 14, 2015. No changes.
  3. Gascar ShunT renamed this gist Nov 14, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. Gascar ShunT revised this gist Nov 14, 2015. 1 changed file with 4 additions and 11 deletions.
    15 changes: 4 additions & 11 deletions Open iterm tab here
    Original file line number Diff line number Diff line change
    @@ -21,17 +21,10 @@ end run
    on CD_to(theDir)
    tell application "iTerm"
    activate
    try
    set t to the last terminal
    on error
    set t to (make new terminal)
    end try
    tell t
    launch session "Default Session"
    tell the last session
    write text "cd " & theDir
    write text "ls"
    end tell
    set go_dir to "cd " & theDir
    set newWindow to (create window with default profile)
    tell current session of first window
    write text go_dir
    end tell
    end tell
    end CD_to
  5. eric-hu revised this gist Jun 23, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Open iterm tab here
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,8 @@ on run {input, parameters}
    tell application "Finder"
    set my_file to first item of input
    set filetype to (kind of (info for my_file))
    -- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
    -- http://stackoverflow.com/a/6881524/640517
    if filetype is "Folder" or filetype is "Volume" then
    set dir_path to quoted form of (POSIX path of my_file)
    else
  6. eric-hu created this gist Jun 23, 2013.
    35 changes: 35 additions & 0 deletions Open iterm tab here
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    -- Adapted from these sources:
    -- http://peterdowns.com/posts/open-iterm-finder-service.html
    -- https://gist.github.com/cowboy/905546
    --
    -- Modified to work with files as well, cd-ing to their container folder
    on run {input, parameters}
    tell application "Finder"
    set my_file to first item of input
    set filetype to (kind of (info for my_file))
    if filetype is "Folder" or filetype is "Volume" then
    set dir_path to quoted form of (POSIX path of my_file)
    else
    set dir_path to quoted form of (POSIX path of (container of my_file as string))
    end if
    end tell
    CD_to(dir_path)
    end run

    on CD_to(theDir)
    tell application "iTerm"
    activate
    try
    set t to the last terminal
    on error
    set t to (make new terminal)
    end try
    tell t
    launch session "Default Session"
    tell the last session
    write text "cd " & theDir
    write text "ls"
    end tell
    end tell
    end tell
    end CD_to