제목에 내가하고 싶은 일이 정확히 있다고 생각합니다. 새로운 iTerm 탭을 실행하고 Finder에서 열린 위치로 위치를 변경하는 Finder 내의 바로 가기 또는 버튼이 필요합니다. 일종의 open .
역이다. 🙂
감사합니다, Malax
답변
OpenTerm 여기 AppleScript 가 있는데 대신 iTerm을 호출하도록 수정할 수 있습니다. 이 MacOSXHints 게시물 도 도움이 될 것입니다.
(저는 Mac에 없습니다. 그렇지 않으면 테스트합니다.)
답변
이 사과는 나를 위해 작동합니다 :
-- script was opened by click in toolbar
on run
tell application "Finder"
try
set currFolder to (folder of the front window as string)
on error
set currFolder to (path to desktop folder as string)
end try
end tell
CD_to(currFolder, false)
end run
-- script run by draging file/folder to icon
on open (theList)
set newWindow to false
repeat with thePath in theList
set thePath to thePath as string
if not (thePath ends with ":") then
set x to the offset of ":" in (the reverse of every character of thePath) as string
set thePath to (characters 1 thru -(x) of thePath) as string
end if
CD_to(thePath, newWindow)
set newWindow to true -- create window for any other files/folders
end repeat
return
end open
-- cd to the desired directory in iterm
on CD_to(theDir, newWindow)
set theDir to quoted form of POSIX path of theDir as string
tell application "iTerm"
activate
delay 1
-- talk to the first terminal
try
set myterm to the first terminal
on error
set myterm to (make new terminal)
end try
tell myterm
try
-- launch a default shell in a new tab in the same terminal
launch session "Default Session"
on error
display dialog "There was an error creating a new tab in iTerm." buttons {"OK"}
end try
tell the last session
try
-- cd to the finder window
write text "cd " & theDir
on error
display dialog "There was an error cding to the finder window." buttons {"OK"}
end try
end tell
end tell
end tell
end CD_to
답변
이 페이지의 다른 답변을 사용하여 파인더 작업 표시 줄로 드래그 할 수있는 앱을 만들었습니다.
https://github.com/rc1/iTermTo 에서 다운로드 할 수 있습니다.
답변
버전 3.1.0부터 iTerm2에 내장되어 있습니다.
기능을 사용하려면 :
Finder에서 폴더-> 서비스-> 새 iTerm2 창을 마우스 오른쪽 단추로 클릭하십시오.
참고 : Services
하위 메뉴는 마우스 오른쪽 버튼 클릭 메뉴의 맨 아래에 있습니다.
참조
링크에서는 클릭 보기 이전 버전을 다음에서, 3.1.0 iTerm2 클릭 표시 변경 내역 과에 대한보기 서비스는 , 당신이 찾을 수 있습니다 :
파인더 서비스에 대한 지원을 추가하십시오. Finder에서 마우스 오른쪽 버튼을 클릭하여 해당 위치에서 iTerm2를 시작할 수 있습니다.
답변
https://github.com/jbtule/cdto
“Finder Toolbar 앱에서 cdto
호스팅 되는 프로젝트를 살펴보고 터미널 (또는 iTerm, X11)에서 현재 디렉토리를 엽니 다.이 앱은 (아이콘 포함) 파인더 창의 툴바 “
답변
완전성을 위해이 질문을 찾기 전에 나에게 도움이 된 것은 다음과 같습니다.
- 적응 new_tab.sh 애플 스크립트 전용 솔루션 (애플 스크립트는 bash는 스크립트에 의해 발행).
- 다음에서
Applescript Editor-> File-> Export-> File Format = .app
. .app
Finder의 툴바로 끌어다 놓습니다.
그러면 Finder 도구 모음 단추가 나타나고 현재 iTerm2
탭 이 새 탭 에서 열립니다 . XtraFinder는 이러한 버튼을 제공하지만 새 창이 열립니다.
서비스를 사용하는 유사한 솔루션은 여기 에서 찾을 수 있으며 , 더 많은 관련 AppleScript 솔루션으로 연결됩니다.
- iTerm 탭을여십시오 .
- 현재 폴더에서 iTerm을 엽니 다 .
- Finder가 여기 iTerm을 엽니 다 .
- 새 용어 탭에서 현재 파인더 창 열기 (특히 2005 년부터).
내가 적응 한 AppleScript는 다음과 같습니다.
try
tell application "iTerm2"
tell the last terminal
launch session "Default Session"
tell the last session
tell i term application "Finder"
set cur_dir to (the target of the front Finder window) as string
end tell
set cur_dir to POSIX path of cur_dir
write text "cd " & cur_dir
end tell
end tell
end tell
end try
이 솔루션은 이 버튼 관련 스레드 에서 주석 처리되었습니다 .
위 의 iTermTo 답변에 감사드립니다 .
답변
iTerm의 내부가 바뀌었기 때문에 그 해결책이 없었습니다. 다음 코드는 무엇입니까?
tell application "Finder"
set cur_dir to POSIX path of ((the target of the front Finder window) as string)
end tell
tell application "iTerm"
tell (create window with default profile)
write current session text "cd " & quoted form of cur_dir
end tell
end tell
또는 Automator를 파인더 서비스로 사용 :
on run {input, parameters}
tell application "Finder"
set cur_dir to POSIX path of (input as string)
end tell
tell application "iTerm"
tell (create window with default profile)
write current session text "cd " & quoted form of cur_dir
end tell
end tell
end run