Programing

Sublime Text 3에서 현재 파일 경로를 (쉽게) 얻는 방법

lottogame 2020. 8. 14. 08:12
반응형

Sublime Text 3에서 현재 파일 경로를 (쉽게) 얻는 방법


Sublime Text 3에서 현재 파일 경로를 (쉽게) 얻는 방법

나는 자주 ST 콘솔을 사용하지 않지만 ( 패키지 관리자를 설치하기 위해 한 번만 사용함 ) 다음과 같은 좋은 방법이 될 수 있다고 생각합니다.

  • 일종의 pwd 명령 과 같은 현재 파일 경로를 가져옵니다 .
  • 하지만 작동하지 않습니다.

누구든지 현재 파일 경로를 얻는 쉬운 방법을 알고 있습니까?

  • 클립 보드에 : 대답의 엄격한 목표가 아닌 것이 좋습니다.
  • ST 명령에 필요하지 않습니다. 패키지일까요?

파일의 아무 곳이나 마우스 오른쪽 버튼으로 클릭 (제목 탭이 아님)-> 파일 경로 복사

마우스를 사용하지 않으려면 여기에 설명 된대로 키보드 단축키를 설정할 수 있습니다. https://superuser.com/questions/636057/how-to-set-shortcut-for-copy-file-path-in -숭고한 텍스트 -3


현재 파일 경로를 쉽게 복사하려면 다음을에 추가하십시오 Key Bindings - User.

{ "keys": ["ctrl+alt+c"], "command": "copy_path" },

출처

Key Bindings - User명령 팔레트를 통해 열 수 있음 ( command + pOSX에서)


이미지를 사용하여 이해하기 쉽습니다. 마우스 오른쪽 버튼을 클릭하면 이것을 얻을 수 있습니다.

여기에 이미지 설명 입력

편의를 위해 이미지에 전사 된 코드 :

import sublime, sublime_plugin, os

class CopyFilenameCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        if len(self.view.file_name()) > 0:
            filename = os.path.split(self.view.file_name())[1]
            sublime.set_clipboard(filename)
            sublime.status_message("Copied file name: %s" % filename)

    def is_enabled(self):
        return self.view.file_name()...  # can't see

Mac OS X-Sublime Text 3

>파일 경로 복사를 마우스 오른쪽 버튼으로 클릭합니다.

여기에 이미지 설명 입력


상태 표시 줄 안에 현재 파일 위치를 제공하는 Sublime 패키지가 있습니다. 방금 내 / sublime-text-3 / Packages 폴더에 직접 복제했습니다.

git clone git@github.com:shagabutdinov/sublime-shell-status.git ShellStatus;

git clone git@github.com:shagabutdinov/sublime-status-message.git StatusMessage;

GitHub에서 설명을 확인 / 읽어야합니다. 패키지 제어에 나열되어 있어도 제대로 설치되지 않습니다. 실제로 원하는대로 셸 출력을 편집 할 수 있습니다. python / shell에 대한 올바른 기술이 있다면.

(머티리얼 테마) 여기에 이미지 설명 입력


이 링크로 이동합니다 . 링크의 코드는 robertcollier4에 의해 제공됩니다 .

Create a file named CpoyFileName.py or whatever you like with .py extension.

Save the file in Sublime Text 3\Packages\User folder. Then paste the above given key bindings in your Preferences: Key Bindings file.

Now, you can use the specified key bindings to copy just filename or total (absolute) filepath.

Please note that the filename or filepath do contain file extension.


If you're like me and always click on items in the sidebar just to realize that copying the path only works when clicking in the editor area, have a look at the SideBarEnhancements package. It has a huge bunch of options to copy file paths in a variety of different ways.

Installation is available via Package Control (despite the webpage only mentions installation via manual download).

참고 : 패키지는 "기본, 익명 통계 전송" . 웹 페이지는이를 거부하는 방법을 설명합니다.

SublimeSideBarEnhancements 스크린 샷

참고 URL : https://stackoverflow.com/questions/29743615/how-to-easily-get-current-file-path-in-sublime-text-3

반응형