Sublime Text from Command Line

前端 未结 27 2110
时光说笑
时光说笑 2020-11-27 08:37

I installed Sublime Text and wanted to know how to open rb files in it from the terminal. I saw What is the command to make Sublime Text my core editor? and I s

27条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 09:21

        @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 
    

提交回复
热议问题