programing

명령 줄의 숭고한 텍스트

new-time 2020. 5. 15. 22:40
반응형

명령 줄의 숭고한 텍스트


Sublime Text를 설치

rb

하고 터미널에서 파일 을 여는 방법을 알고 싶었습니다 .

Sublime Text를 핵심 편집자로 만드는 명령

무엇입니까? Sublime을 핵심 편집기로 만들 수 있지만 입력 할 수 있기를 원합니다.

sublime file.rb

Windows에서 어떻게해야합니까?


빌드

3065

(릴리스 날짜 : 2014 년 8 월 29 일)부터는

Sublime text

명령 행 도우미 nameley가 포함

subl.exe

됩니다. 숭고한 설치 폴더에 있습니다. 시스템 경로에 포함 된 폴더에 복사하십시오. 예를 들어, 제 경우에는 복사했습니다...에서

C:\Program Files\Sublime Text 3

C:\Windows\System32

그런 다음 터미널 / 콘솔

subl

에서 명령으로 사용하여 예와 같이 파일을 열 수 있습니다.

subl file.rb

또는

PATH

숭고한 설치 폴더를 포함하도록 시스템 변수를 수정할 수도 있지만 훨씬 더 관련이 있다고 생각합니다.


Windows 명령 프롬프트

Windows cmd.exe의 경우 숭고한 텍스트 설치 디렉토리를 PATH 환경 변수에 추가하면 다음과 같이 입력 할 수 있습니다.

sublime_text file.rb

개인적 으로 cmd자동 실행 되도록 설정된 .bat 파일에

doskey를

추가하여 다음을

입력

할 수 있습니다

subl file.rb

.

> doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*

사이 그윈

기본 bash 쉘의 경우

~/.bashrc

파일에 별명을 추가 하십시오 (예 :

$ echo 'alias subl="/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.bashrc

이것을

PowerShell 프로필에

추가했습니다 .

Set-Alias subl 'C:\Program Files\Sublime Text 2\sublime_text.exe'

Sublime Text 3 (또는 이후 버전)에 필요한 경우이를 수정하십시오.


또 다른 아이디어는

C:\Program Files\Sublime Text 2\

PATH 에 포함 시킨 다음 관리자 명령 프롬프트를 실행하는 것입니다.

cd "C:\Program Files\Sublime Text 2\"
mklink sublime.exe sublime_text.exe

그러면 새로운 이름과 심볼릭 링크가 만들어집니다. 이제 자유롭게 사용할 수 있습니다.

sublime hello.txt

업데이트

:이 트릭을 사용하고 Sublime Text 2를 업데이트 한 후에 새 빌드로 업데이트해도 기호 링크에 영향을 미치지 않는다는 것을 기쁘게 생각합니다.


C : \ Program Files \ Sublime Text 2에 subl.bat를 내용으로 만들었습니다.

start sublime_text.exe %*

이제 PATH에 C : \ Program Files \ Sublime Text 2가 있으므로 'subl folder'를 입력하면 자동 시작에 아무것도 추가하지 않고도 훌륭하게 작동합니다.


Windows 에서

환경 변수

설정하는 것이 더 쉽다고 생각합니다 .그런 다음 마지막에이 값 "; % SUBLIME_HOME %" (따옴표없이)을 추가하여 Path 경로를 편집 한 후 값이 "C : \ Program Files \ Sublime Text 2 \" (따옴표없이)SUBLIME_HOME 이라는

시스템 변수를

추가하십시오 .다음 같이

git BASH를

다시 시작 하고 즐기십시오.$ sublime_text

mi-new-file

(

sublime_text

는 명령 임)

참고 :

Windows의 cmd에서도 작동합니다.


설치 경로를 Windows 경로에 추가하면 실행 파일 이름 (기본적으로 "

subl

") 을 입력하여 Sublime을 열 수 있습니다 .Windows 경로에 Sublime 설치 폴더를 포함 시키려면

  1. 명령 프롬프트를 열고 입력 sysdm.cpl
  2. 고급 탭에서 Environment variables
  3. 시스템 변수에서 " Path" 변수를 선택하고을 클릭하십시오 Edit.
  4. C:\Program Files\Sublime Text 3;기존 문자열 끝에 " "를 추가하십시오 .
  5. 변경 사항을 저장하고 명령 프롬프트를 다시 시작 하십시오 .

나는이 스레드가 조금 오래되었다는 것을 알고 있지만 최근 에이 솔루션을 생각해 내고 공유 할 것이라고 생각했습니다 ...Cygwin을 사용하는 경우 유닉스 경로 이름을 Windows 경로로 변환하고 숭고한 것으로 전달하는 bash 스크립트를 만들 수 있습니다. 다음을 새 파일에 붙여 넣습니다.

#!/bin/bash

/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe `cygpath -w $@` &

에 저장

/usr/bin/subl

하거나 원하는 위치에 저장하고

$PATH

실행 가능하게 만드십시오 (

$ chmod a+x /usr/bin/subl

).이 스크립트를 사용 하면 유틸리티가 경로 별칭을 해당하는 창으로 변환 하기 때문에 UNIX 및 Windows 스타일 경로 (

/cygdrive/c/

또는

C:/

)를 모두 사용할 수 있습니다 .

cygpath

 

/

 

~

이제

$ subl file1.txt file2.md ~/file3.txt

파일을 숭고하게 열 수 있습니다 !


Windows의 레일에서 루비를 시험 해보고 경로를 포함시킨

C:\Program Files\Sublime Text 2\

다음 이름

sublime.exe

subl.exe.

일반 cmd 및 "ruby 및 rails를 사용한 명령 프롬프트"cmd에서 제대로 작동했습니다.


 

허용 대답은

직접적으로 파일을 복사 윈도우 7에 숭고한 텍스트 3 이상에서 작동하지 않습니다

C:\Windows\System32

수 있습니다

subl

쉘에서 해결의 벌금을,하지만 난 그것을 실행하면 아무 일도 발생하지 않습니다.하드 링크로 더 많은 성공을 거두었습니다.

mklink /h c:\windows\system32\subl.exe "c:\Program Files\Sublime Text 3\subl.exe"

그것으로,

subl <file.txt>

그리고

subl <directory>

둘 다 잘 작동합니다.


숭고한 텍스트를 시작하기 위해 Windows 디렉토리에 간단한 배치 파일 (s.bat)을 만들었습니다.이것은 Sublime Text 2를 시작하기 위해 배치 파일에 넣은 코드입니다.

@start "sublime" "%ProgramW6432%\Sublime Text 2\sublime_text.exe" %*

입력하여 숭고한 전화

s

직접 사용하여 파일을 엽니 다

s filename.ext

방금 명령 프롬프트 프로그램을 관리자로 실행하고 다음 명령을 실행했습니다.

 

간단하지만 나를 위해 작동합니다.

echo "c:\Program Files\Sublime Text 3\subl.exe" %1 > %systemroot%\system32\subl.bat

물론 원하는대로 박쥐 파일을 호출 할 수 있습니다. 그때부터는 모든 사용자가 간단하게 사용할 수 있습니다.

subl myfile.txt

Cmder를 사용하는 경우 cmder를 설치 한 위치에있는 별칭 파일에 별칭을 추가 한 다음 config \ aliases를 추가 할 수 있습니다 그런 다음 추가 할 수 있습니다 (이것은 숭고한 텍스트입니다 3)

subl="C:\Program Files\Sublime Text 3\sublime_text.exe" $1

Cmder 내에서 다음을 통해 숭고한 디렉토리를 열 수 있습니다.

subl="C:\Program Files\Sublime Text 3\sublime_text.exe" $1

이 시도:

alias subl='"/c/Program Files/Sublime Text 2/sublime_text.exe"'

숭고한 설치 디렉토리를 확인하십시오. 숭고한 별명을 작성한 후 다음을 입력하십시오.

subl file.rb

레지스트리에서 작성하십시오.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\sublime.exe

update value of default parametr (REG_SZ) to:

C:\Program Files\Sublime Text 2\sublime_text.exe


  • Set the path for sublime: My computer >> properties >> advanced setting >> environment variables >> path variable >> Add>> C:\Program Files\Sublime Text 3

  • Just go to directory where sublime is installed and rename sublime_text to sublime.

Open command prompt and type sublime.


This powershell allows me to pipe to the edit function (or to use it in the normal way)

function edit
{
    param( [Parameter(ValueFromPipeline=$true,Position=0)] $file )
    begin { set-alias EDITOR 'W:\tools\sublime_text.bat' }
    process { EDITOR $file }
}

here is the sublime_text.bat which for some reason seems necessary (anyone know why?)

START "Sublime Text 2" "C:\Program Files\Sublime Text 2\sublime_text.exe" %*

I wanted to start a new instance of Sublime Text from the command-line.. The following page helped me, even though it only says OSX: http://www.sublimetext.com/docs/3/osx_command_line.html.

So, I use a batch file in my user path to launch 'sublime'. Here is basically what I use (**the batch file contents):

@start "sublime" "%~dp0Sublime Text\sublime_text.exe" --new-window %*

(my batch file %~-dp0 is located one folder above the Sublime Text installation path.)

I know this is an old thread, but I thought I'd add what I was looking for (and found). It might help someone else!


You can simply install Notepad Replacer http://www.binaryfortress.com/NotepadReplacer/ what it will do is make sublime your default notepad in Windows and then you can simply use the commands that you generally use to open inbuilt notepad in windows. for example

`//to open test.txt, just type
notepad test.txt
//to open sublime, Type
notepad`

Going off the most accepted answer, but whose author unfortunately said modifying the PATH is "hard" - it's not at all. It's very easy. I just did it, and you can too!

Here's what to do:

Navigate to your sublime text directory in Windows Explorer and copy the full path from the path bar.

For example, I have a few development tools set up as portable applications in Dropbox, so I copied the path:

C:\Users\username\Dropbox\Programs\Sublime Text Build 3114 x64

Go to Control panel-> System-> Advanced System Settings-> Environment Variables

In the resulting window, navigate to "path" in the bottom window, highlight it and click "Edit".

In the window that appears, click "New", paste in your Sublime Text path, and click "OK".

Now open CMD or Powershell and type subl

Sublime Text window should open. Enjoy!

Note: I noticed someone else answered this in a similar fashion, but used a fixed location for Sublime Text. That may work for some people, but for others the directions will be erroneous. The fact is, the Sublime Text location can be anywhere on the drive, and knowing where it is and copying that particular location is one of the most important parts of assigning the PATH variable.


Hollow every one.

I build a very easy way to do this.

project github page

just download "install.bat" and right click on install.bat -> click "run as administrator"


add Sublime's installation folder to your path. @set PATH=C:\Program Files\Sublime Text 3;%PATH%

or

To set an environment variable permanently in Windows (so that it is available to all the Windows' processes),

start the "Control Panel" ⇒ "System" ⇒ (Vista/7/8) "Advanced system settings" ⇒ Switch to "Advanced" tab ⇒ "Environment variables" ⇒ Choose "System Variables" (for all users) or "User Variables" (for this login user only) ⇒ Choose "Edit" (for modifying an existing variable) or "New" (to create a new variable) ⇒ Enter the variable "Name" and "Value".

in that case prepend C:\Program Files\Sublime Text 3 to the path.

Now, can make a copy of 'sublime_text.exe' as 'sublime.exe'

Then in any command prompt you may be able to run a file.txt file by

C:\Users\MyUsername>sublime filename.txt

If you don't want to change your path you can associate files with sublime. So right click on the file, click properties, then click opens with sublime text.

From the command line: myFile.py

Will open the file in sublime. I suppose this saves you about five keystrokes.


  1. In the Environmental variable I added %SUBLIME_HOME% variable to the path variable as well

  2. Then made a symbolic link from my Command terminal

mklink sb sublime_text.exe

    @echo off
    :: File: TextFiles.Starter.DESKTOP-M175NUE.cmd v1.1.0 docs at the end 

    :: this just an iso-8601 wrapper for windows:
    :: src: http://www.cs.tut.fi/~jkorpela/iso8601.html
    call GetNiceTime.cmd

    :: go the run dir
    cd %~dp0z

    :: this is the dir containing the batch file
    set _MyDir=%CD%

    :: look around , set vars
    for %%A in (%0) do set _MyDriveLetter=%%~dA
    for %%A in (%0) do set _MyPath=%%~pA
    for %%A in (%0) do set _MyName=%%~nA
    for %%A in (%0) do set _MyEtxtension=%%~xA

    :: contains absolute file paths of the files to open like this
    set _ListFile=%_MyDir%\%_MyName%.lst
    :: example of lines in the list file - take out the ::space
    :: C:\Users\ysg\Desktop\TextFiles.Starter.DESKTOP-M175NUE.cmd
    :: C:\Users\ysg\Desktop\TextFiles.Starter.DESKTOP-M175NUE.lst


    :: set _Program="C:\Program Files\TextPad 8\TextPad.exe"
    set _Program="C:\Program Files\Sublime Text 3\sublime_text.exe"
    set _
    :: DEBUG PAUSE

    :: sleep 2
    ping -n 2 www.google.com > NUL

    :: for each line of the cat file do open 
    :: for TextPad , obs note the quoting 
    :: for /f "tokens=*" %%i in ('type "%_ListFile%"') do ^
    :: cmd /c "%_Program% "%%i""

    :: for sublime, obs note the quoting 
    for /f "tokens=*" %%i in ('type "%_ListFile%"') do ^
    cmd /c "%_Program% -t "%%i""
    :: DEBUG PAUSE

    :: Purpose: 
    :: to start a list of non-binary files from a list file on Windows 10
    :: Tested on Windows 10, should work on Win7 too
    :: 
    :: Requirements:
    :: TextPad 8 or Sublime
    :: 
    :: 
    :: Usage: 
    :: copy this file onto your Desktop, list the absolute paths in to the list file 
    :: change the program name in the _Program if if you want other editor
    :: 
    :: VersionHistory: 
    :: 1.1.0 --- 2017-10-06 09:42:54 --- ysg --- added sublime 
    :: 1.0.1 --- 2013-04-15 08:19:10 --- ysg --- added - todo-%today%.txt file opening
    :: 1.0.0 --- 2012-05-23 09:08:57 --- ysg -- Initial creation 

참고URL : https://stackoverflow.com/questions/9440639/sublime-text-from-command-line

반응형