MACOS X: Как иметь удобное, “Открытое эта папка в iTerm” ярлык?

Я думаю состояния заголовка точно, что я хочу сделать. Я хочу ярлык или даже кнопку в Средстве поиска, которое разжигает новую iTerm Вкладку и изменяет местоположение к расположению, которое я имею открытый в Средстве поиска. Своего рода open . наоборот.:-)

Спасибо, Размягчите

12
задан 08.01.2010, 21:44

3 ответа

Существует Открыть Terminal Here AppleScript, который необходимо смочь изменить для вызова iTerm вместо этого. Это сообщение MacOSXHints должно быть полезным также.

(Я не нахожусь на своем Mac иначе, я протестировал бы его.)

5
ответ дан 07.12.2019, 11:47

Смотрите на cdto проект, размещенный на https://github.com/jbtule/cdto "Приложение Панели инструментов средства поиска для открытия текущего каталога в Терминале (или iTerm, X11). Это приложение разработано (включая его значок) к помещенному в панель инструментов окна средства поиска".

2
ответ дан 07.12.2019, 11:47

Этот applescript работает на меня:

-- 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
10
ответ дан 07.12.2019, 11:47

Теги

Похожие вопросы