programing

Mac OS 파인더에서 여기에서 터미널 열기

nasanasas 2020. 9. 30. 10:57
반응형

Mac OS 파인더에서 여기에서 터미널 열기


Mac OS 용 Windows Powertoy "여기에서 명령 창 열기"와 유사한 것이 있습니까? Google 검색을 통해 몇 가지 플러그인을 찾았지만 개발자에게 가장 적합한 플러그인을보고 싶었습니다.


Mac OS X Lion 10.7부터 터미널은 정확히이 기능을 서비스로 포함합니다. 대부분의 서비스와 마찬가지로 이러한 서비스는 기본적으로 비활성화되어 있으므로 서비스 메뉴에 나타나게하려면 활성화해야합니다.

시스템 환경 설정> 키보드> 단축키> 서비스

폴더에서 새 터미널을 활성화 합니다 . 또한 폴더에 새 터미널 탭이있어 맨 앞 터미널 창에 탭을 생성합니다 (있는 경우 새 창을 생성합니다). 이러한 서비스는 Finder뿐만 아니라 모든 응용 프로그램에서 작동하며 텍스트에서 선택한 절대 경로 이름뿐 아니라 폴더에서도 작동합니다.

명령 키를 할당 할 수도 있습니다.

서비스는 각 응용 프로그램 메뉴의 서비스 하위 메뉴와 상황에 맞는 메뉴 (폴더 또는 경로 이름을 Control- 클릭 또는 마우스 오른쪽 단추 클릭)에 나타납니다.

Finder 에서 폴더를 선택하면 폴더새 터미널 서비스가 활성화 됩니다 . 단순히 폴더를 열고 "제자리에서"서비스를 실행할 수는 없습니다. 상위 폴더로 돌아가서 관련 폴더를 선택한 다음 서비스 메뉴 또는 컨텍스트 메뉴를 통해 서비스를 활성화하십시오.

또한 Lion Terminal은 폴더 (또는 경로 이름)를 터미널 응용 프로그램 아이콘으로 드래그하면 새 터미널 창이 열리고 기존 창의 탭 표시 줄로 드래그하여 새 탭을 만들 수도 있습니다.

마지막으로 폴더 또는 경로 이름을 탭 (탭 표시 줄)으로 드래그하고 포 그라운드 프로세스가 셸인 경우 자동으로 "cd"명령을 실행합니다. (탭 내에서 터미널보기로 드래그하면 이전 버전의 터미널에서와 같이 자체 경로 이름 만 삽입됩니다.)

명령 줄이나 셸 스크립트에서도이 작업을 수행 할 수 있습니다.

open -a Terminal /path/to/folder

이는 폴더 / 경로 이름을 터미널 응용 프로그램 아이콘으로 끌어 오는 것과 같은 명령 줄입니다.

관련 메모에서 Lion Terminal에는 man 페이지를 조회 할 수있는 새로운 서비스도 있습니다. Terminal에서 man page 열기 는 새 터미널 창에 선택된 man page 항목을 표시하고 Search man Pages in Terminal 은 선택한 텍스트에 대해 "apropos"를 수행합니다. 전자는 또한 매뉴얼 페이지 참조 ( "open (2)"), 매뉴얼 페이지 명령 줄 인수 ( "2 open") 및 매뉴얼 페이지 URL ( "x-man-page : // 2 / open")을 이해합니다.


이:

https://github.com/jbtule/cdto#cd-to

Finder 툴바로 드래그하는 작은 앱으로 아이콘이 아주 잘 맞습니다. 터미널, xterm (X11 아래), iterm에서 작동합니다.


대안으로 없어서는 안될 응용 프로그램은 실제로 응용 프로그램에서 바로 미니 터미널을 여는 DTerm 입니다. 또한 Finder, XCode, PhotoShop 등 거의 모든 것과 함께 작동합니다.


설명 (@ vgm64에게 감사) : 이미 터미널에있는 경우 터미널을 벗어나지 않고도 맨 위의 Finder 창으로 빠르게 변경할 수 있습니다. 이렇게하면 마우스 사용을 피할 수 있습니다.

언제든지 터미널에 .bash_profile입력 할 수 있도록 다음을 추가했습니다 cdff.

function ff { osascript -e 'tell application "Finder"'\
 -e "if (${1-1} <= (count Finder windows)) then"\
 -e "get POSIX path of (target of window ${1-1} as alias)"\
 -e 'else' -e 'get POSIX path of (desktop as alias)'\
 -e 'end if' -e 'end tell'; };\

function cdff { cd "`ff $@`"; };

이것은 macosxhints.com 터미널 힌트 에서 가져온 것 입니다.


Open Terminal Here를 확인하십시오 . "여기에서 명령 창 열기"와 가장 유사 할 수 있습니다. 나는 사용 >cdto했고 이것은 매우 유사하지만 이것은 Spaces를 다루는 데 조금 더 나은 것처럼 보이지만 완벽하지는 않습니다.

매우 좋은 점은 " 애플리케이션 시작시 키 다운 이벤트를 감지하여 스크립트의 동작을 수정하는 데 사용 "하는 기능으로, 호출시 스크립트가 가장 앞쪽 터미널 창에서 새 탭을 열 수 있도록합니다. ⌘ 키를 누르고 있습니다. 깔끔한 트릭.

또한 PCheese의 답변에 유의하십시오. 무거운 터미널 사용자에게 더 유용 할 것입니다!


vgm64d0k 에 의해 게시 된 매우 멋지고 슬림 한 오픈 터미널 의 업데이트 된 버전이 있습니다. 변경 사항은 제임스 데이비드 로우에 의해 이루어졌습니다 . 그는 자신의 사이트 에 새 버전을 게시했습니다 . OpenTerminalHere.zip을 다운로드하고 압축을 푼 다음 번들을 Library / Scripts 폴더로 이동 한 다음 여기에서 Finder 도구 모음으로 드래그하면됩니다.

특별한 점은 Terminal.app 창이 이미 열려 있으면 항상 새 탭 이 열린다는 것입니다. 굉장히 유용하다! 또한 응용 프로그램의 버튼 스타일이 redacted게시 한 cdto보다 Snow Leopard Finder.app 스타일에 더 잘 맞는다는 점에 주목했습니다 .


Also, you can copy an item from the finder using command-C, jump into the Terminal (e.g. using Spotlight or QuickSilver) type 'cd ' and simply paste with command-v


I created a bundle with 3 apps for the finder toolbar. The other two apps do:

  • open Textmate with the current selection
  • open GitX with the current folder

For more information see here: http://nslog.de/posts/71


If you install Big Cat Scripts (http://www.ranchero.com/bigcat/) you can add your own contextual menu (right click) items. I don't think it comes with an Open Terminal Here applescript but I use this script (which I don't honestly remember if I wrote myself, or lifted from someone else's example):


on main(filelist)
    tell application "Finder"
        try
            activate
            set frontWin to folder of front window as string
            set frontWinPath to (get POSIX path of frontWin)
            tell application "Terminal"
                activate
                do script with command "cd \"" & frontWinPath & "\""
            end tell
        on error error_message
            beep
            display dialog error_message buttons ¬
                {"OK"} default button 1
        end try
    end tell
end main

Similar scripts can also get you the complete path to a file on right-click, which is even more useful, I find.


It's a bit more than you're asking for, but I recommend Cocoatech's Path Finder for anyone who wishes the Finder had a bit more juice. It includes a toolbar button to open a Terminal window for the current directory, or a retractable pane with a Terminal command line at the bottom of each Finder window. Plus many other features that I now can't live without. Very mature, stable software. http://cocoatech.com/


Ok, I realize that this is a bit late... maybe this alternative wasn't available at the moment of writing the post?

Anyway, I've found installing the pos package via Fink (a prerequisite in this case, maybe there is something similar for those who uses MacPorts?) to be the easiest solution. You get two commands:

  1. posd - which gives the current directory of the frontmost Finder window (for which you presumably make an alias cdf=cd posd)
  2. fdc - which switches the current directory of the frontmost Finder window to the Terminal pwd. This is slightly different from 'open .' which always opens a new finder window.

Yes, you have to switch to the Terminal window before writing cdf, but I suppose that's quite cheap comparing to clicking a button in the Finder toolbar. And it works with iTerm as well, you don't have to download a separate Finder toolbar button that opens an iTerm window. This is the same approach as proposed by PCheese, but you don't have to clutter your .bash_profile.


If like me you turn off the Finder toolbar, this Service adds an item to every folder's contextual menu: http://blog.leenarts.net/2009/09/03/open-service-here/

This also allows you to open any folder you see in Finder tree view.


I mostly use this function:

cf() {
  cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}

You could also assign a shortcut to a script like the ones below.

Reuse an existing tab or create a new window (Terminal):

tell application "Finder" to set p to POSIX path of (insertion location as alias)
tell application "Terminal"
    if (exists window 1) and not busy of window 1 then
        do script "cd " & quoted form of p in window 1
    else
        do script "cd " & quoted form of p
    end if
    activate
end tell

Reuse an existing tab or create a new tab (Terminal):

tell application "Finder" to set p to POSIX path of (insertion location as alias)
tell application "Terminal"
    if not (exists window 1) then reopen
    activate
    if busy of window 1 then
        tell application "System Events" to keystroke "t" using command down
    end if
    do script "cd " & quoted form of p in window 1
end tell

Always create a new tab (iTerm 2):

tell application "Finder" to set p to POSIX path of (insertion location as alias)
tell application "iTerm"
    if exists current terminal then
        current terminal
    else
        make new terminal
    end if
    tell (launch session "Default") of result to write text "cd " & quoted form of p
    activate
end tell

The first two scripts have two advantages compared to the services added in 10.7:

  • They use the folder on the title bar instead of requiring you to select a folder first.
  • They reuse the frontmost tab if it is not busy, e.g. running a command, displaying a man page, or running emacs.

There is a bug in the AppleScript on OSX 10.6. (2 terminal windows open). I fixed this by adding the close command after activate. This close the first Terminal window.

on run
    tell application "Finder"
        try
            activate
            set frontWin to folder of front window as string
            set frontWinPath to (get POSIX path of frontWin)
            tell application "Terminal"
                activate
                close
                do script with command "cd \"" & frontWinPath & "\""
            end tell
        on error error_message
            beep
            display dialog error_message buttons ¬
                {"OK"} default button 1
        end try
    end tell
end run

참고URL : https://stackoverflow.com/questions/420456/open-terminal-here-in-mac-os-finder

반응형