Finder.app의 해당 디렉토리에서 iTerm2 열기

예전에는 Go2Shell이라는 앱으로 잘 되었었는데,
OSX가 메이저 업데이트 되면서 Go2Shell 관리는 안 하는 것인지 제대로 작동을 안 한다.

그래서 구글링을 하다가 찾은 해결책은 다음과 같다.
해결책 원본은 https://gist.github.com/pdanford/158d74e2026f393e953ed43ff8168ec1

  1. Automator를 켜고 파일 -> 새로 만들기 에서 Application을 선택한다.
  2. Automator에서 라이브러리 -> 유틸리티 -> 애플스크립트 실행을 더블 클릭한다.
  3. 이 글의 제일 아래 있는 AppleScript를 복사해서 붙여넣는다.
  4. Desktop 디렉토리 등에 iTermOpenHereScript.app라는 이름으로 저장한다. 그리고 iTermOpenHereScript.app을 ~/Library/Services에 복사한다. (파인더에서 Shift+Command+G를 눌러서 ~/Library/Services 를 입력하면 해당 디렉토리가 열린다.)
  5. 파인더 -> 응용프로그램의 iTerm2.app을 클릭해서 Command+i 를 쳐서 info 창이 나오면 iTerm2 아이콘을 클릭해서 복사(Command+C)한다.
  6. ~/Library/Services에 있는 iTermOpernHereScript.app을 클릭해서 Command+i 를 쳐서 info 창이 나오면 Automator 아이콘을 클릭하고 붙여넣기(Command+V)를 해서 아이콘 모양을 예쁘게 바꿔놓는다.
  7. Command+Option 키를 누른 상태에서 iTermOpenHereScript.app을 드래그해서 Finder.app의 툴바로 끌어다 놓는다.
  8. iTerm2의 환경설정 -> General -> Startup에 가서 Windows restoration policy를 Only Restore Hotkey Window로 선택한다.
  9. iTerm2의 환경설정 -> General -> Closing에 가서 Quit when all windows are closed의 체크표시를 없앤다. 그래서 기동이 빨라진다.

AppleScript

on run {input, parameters}
    set frontApp to (path to frontmost application as Unicode text)
    if (frontApp does not contain "Finder.app") then
        -- Finder does not have focus.
        return
    end if

    tell application "Finder"
        set listSize to count of (every window)
        if listSize is equal to 0 then
            -- The Finder desktop has focus and no windows anywhere else. default to home dir.
            set dir_path to "~"
        else
            try
                set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
            on error errMsg
                -- This is a special dir (e.g. Network or "machine name"). default to home dir.
                set dir_path to "~"
            end try
        end if
    end tell

    CD_to(dir_path)
end run

on CD_to(theDir)
    tell application "iTerm"
        set term_window to (create window with default profile)
        set sesh to (current session of term_window)
        tell sesh to write text "cd " & theDir & ";clear"
    end tell
end CD_to

mosh 설정

연구실 ubuntu와 mac에 mosh를 설정해야겠다.

집에서 접속을 해서 작업을 할 때마다 느려서..


이 글은 처음 쓴지 약 일주일이 지난 것 같다.

지난 이틀 동안 연구실 ubuntu와 mac에 mosh를 설치했다.

ubuntu에는 제대로 설치가 되었고, 작동도 제대로 되었다.

그러나 mac에는 firewall에서 문제를 일으키고 있다.
구글링을 해보니, 나와 같은 문제를 모두 겪고 있었으면 그 누구도 해결책을 찾지 못 한 것 같았다.

그래서 mac에 mosh를 설정하는 것은 포기했다.

요새 ubuntu에는 접속할 일이 거의 없으니, airport에서 port forwarding도 아예 지워버렸다.

결론적으로, mosh는 당분간 사용하지 않을 예정이다.

true color도 제대로 지원하지 않고, mac 방화벽과도 궁합이 맞지를 않으니 말이다.

약간 불편하더라도 당분간은 ssh를 사용할 것 같다.