2016-08-01 2 views
4

임 Iterm2 버전이 코드 시도 내가 (bash는) 명령 줄에서 새 탭을 열 별칭을 만들려면 3.0.4 빌드 사용 :새 탭

function tab() { 
    osascript &>/dev/null <<EOF 
activate application "iTerm" 
    tell application "System Events" to keystroke "t" using command down 
    tell application "iTerm" to tell session -1 of current terminal to write text "pwd" 
EOF 
} 

을하지만 '외설 일하고있어. 누구든지이 버전 (또는 최신 버전)으로 문제를 해결할 수 있습니까?

답변

3

iTerm2 v3은 많이 개선 된 애플 스크립트 지원을 제공합니다, 그래서 당신은 이제 키 입력을 보내지 않고도 직접 탭을 만들 수 있습니다 : 당신이 를 눌러 얻을 것 같은

tab() { 
    osascript &>/dev/null <<EOF 
     tell application "iTerm" 
     activate 
     tell current window to set tb to create tab with default profile 
     tell current session of current window to write text "pwd" 
     end tell 
EOF 
} 

은 (수평으로 새 탭을 분리하기 위해 ⇧⌘ D), 추가

:

tell current session of current window to split horizontally with same profile 

이 분할 (새 탭의 아래쪽 절반)에 의해 생성 된 새로운 세션에 pwd를 작성하려면

tab() { 
    osascript &>/dev/null <<EOF 
     tell application "iTerm" 
     activate 
     tell current window to set tb to create tab with default profile 
     tell current session of current window to set newSplit to split horizontally with same profile 
     tell newSplit 
      select 
      write text "pwd" 
     end tell  
     end tell 
EOF 
} 

Script Editor.app을 열어 iTerm.app을 선택하십시오.

또한 Terminal.appiTerm2.app에 대한 고급 기능과 함께 탭/창 작성 패키지 인 CLI (내재 된 탭 분할은 지원하지 않음)를 고려하십시오.