compute/osx-open-iterm-here.md
... ...
@@ -1,68 +0,0 @@
1
-# Open iTerm at a finder window's path
2
-Modified from [Deep-blue](https://hohonuuli.blogspot.com/2016/02/iterm2-version-3-open-iterm-here-script.html)'s version. I don't use tabs in shells, so this version always opens a new iTerm window.
3
-
4
-Open ScriptEditor from Launchpad and paste this in:
5
-```
6
-(*
7
- Open Terminal Here
8
-
9
- A toolbar script for Mac OS X 10.3/10.4
10
-
11
- Written by Brian Schlining
12
-
13
- Modified by David Stark
14
- *)
15
-
16
-property debug : false
17
-
18
--- when the toolbar script icon is clicked
19
---
20
-on run
21
- tell application "Finder"
22
- try
23
- set this_folder to (the target of the front window) as alias
24
- on error
25
- set this_folder to startup disk
26
- end try
27
- my process_item(this_folder)
28
- end tell
29
-end run
30
-
31
--- This handler processes folders dropped onto the toolbar script icon
32
---
33
-on open these_items
34
- repeat with i from 1 to the count of these_items
35
- set this_item to item i of these_items
36
- my process_item(this_item)
37
- end repeat
38
-end open
39
-
40
--- this subroutine processes does the actual work
41
--- this version can handle this weirdo case: a folder named "te'st"ö te%s`t"
42
-
43
-on process_item(this_item)
44
- set thePath to quoted form of POSIX path of this_item
45
- set theCmd to "cd " & thePath & ";clear;"
46
- if application "iTerm" is running then
47
- tell application "iTerm"
48
- activate
49
- set aWindow to (create window with default profile)
50
- tell current session of aWindow
51
- write text "cd " & thePath & ";clear;"
52
- end tell
53
- end tell
54
- else
55
- tell application "iTerm"
56
- activate
57
- set aWindow to current window
58
- tell current session of aWindow
59
- write text "cd " & thePath & ";clear;"
60
- end tell
61
- end tell
62
- end if
63
-end process_item
64
-```
65
-
66
-Export it as an Application, then drag the application icon up to the Finder toolbar while holding down `option` and `command`.
67
-
68
-Then you can click the icon in the Finder toolbar and iTerm will open at that folder.