2016-10-24 3 views
0

아마도 잘못되었지만 ITerm2 documentation에서 해결책을 찾을 수없는 사소한 구문 문제 일 수 있습니다. 3 개의 탭이있는 ITerm 윈도우를 여는 applescript를 만들고 싶습니다. 각각의 쉘 명령 (ls, cd, echo 등)은 해당 명령이 실행 된 후에 열려있는 탭과 함께 실행됩니다. 오프닝 탭 부분은 잘 작동하지만 여기 내 스크립트 (내가 어떤 명령을 제공하지 않는 경우, 탭이 열린 상태로 유지됩니다.) 즉시 명령이 실행으로, 탭을 닫을 것으로 나타납니다완료 후 탭을 닫지 않고 ITerm2에서 쉘 명령을 실행하십시오.

tell application "iTerm2" 
    create window with default profile 
    tell current window 
    create tab with default profile command "echo abc" 
    create tab with default profile 
    end tell 
end tell 

"echo abc"대신에 echo 명령을 탭에서 실행해야하지만 탭 대신 즉시 명령을 입력하기 위해 커서 대신 명령을 입력해야합니까?

답변

0

create tab ... command을 사용하는 대신 별도의 write text 명령을 사용하십시오. 예를 들어, 내가 특정 디렉토리에 터미널을 여는 데 사용하는 스크립트입니다 : 내가 다음에 정착 whereswalden가 제시 한 "쓰기 텍스트"를 사용

tell application "iTerm" 
    create window with default profile 
    tell current session of current window 
    write text "cd " & directory & "; clear" 
    end tell 
end tell 
0

가 잘 작동합니다

tell application "iTerm2" 
    create window with default profile 
    tell current window 
     tell current session 
     write text "echo abc" 
     end tell 

     create tab with default profile 
     tell current session 
     write text "ls -la" 
     end tell 

     create tab with default profile 
     tell current session 
      write text "cd mydir" 
     end tell 
    end tell 
end tell 
관련 문제