我安装了Sublime Text,想知道如何从终端打开其中的rb文件。我看到让Sublime Text成为我的核心编辑器的命令是什么?我看到我可以让Sublime成为我的核心编辑器,但我想要能够打字
sublime file.rb
在Windows中如何做到这一点?
我安装了Sublime Text,想知道如何从终端打开其中的rb文件。我看到让Sublime Text成为我的核心编辑器的命令是什么?我看到我可以让Sublime成为我的核心编辑器,但我想要能够打字
sublime file.rb
在Windows中如何做到这一点?
当前回答
您可以简单地安装记事本替代品http://www.binaryfortress.com/NotepadReplacer/ 它会做什么是崇高的默认记事本在Windows中,然后你可以简单地使用命令,你通常使用在Windows中打开内置记事本。例如
`//to open test.txt, just type
notepad test.txt
//to open sublime, Type
notepad`
其他回答
@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
以下是我在PowerShell中行之有效的方法:
# CHECK IF YOUR ALIAS FOR SUBLIME TEXT 3 EXISTS
Get-Alias subl
# REMOVE YOUR ALIAS FOR SUBLIME TEXT 3 IF IT EXISTS
# REF 1
Remove-Item alias:subl
# SET YOUR ALIAS FOR SUBLIME TEXT 3
Set-Alias subl -Value "C:\Program Files\Sublime Text 3\sublime_text.exe"
# CREATE A TEST FILE ON YOUR Desktop
# REF 2
echo "Testing`nNew`nFile`n." > $HOME\Desktop\TestFile.txt
# TEST YOUR NEW ALIAS
subl $HOME\Desktop\TestFile.txt
这是设置和测试别名的最简单方法。如果你想在你的个人资料中保留这一点,试试这个:
# TO PERMANENTLY KEEP EVERYTIME YOU OPEN POWERSHELL PLEASE ADD TO YOUR PROFILE. BUT FIRST VERIFY YOUR PROFILE `FILE` EXISTS, IF NOT THEN THIS WILL CREATE IT.
# REF 3 & 4
if (!(Test-Path -Path $PROFILE.CurrentUserAllHosts)) {New-Item -ItemType File -Path $PROFILE.CurrentUserAllHosts -Force}
# open powershell PROFILE
ise $PROFILE.CurrentUserAllHosts
# Add the Set-Alias to your file
Set-Alias subl -Value "C:\Program Files\Sublime Text 3\sublime_text.exe"
REF 1 Remove-Alias: https://superuser.com/q/883914/247728
REF 2换行符:https://stackoverflow.com/a/36738723/1896134
REF 3 https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-5.1
REF 4 https://devblogs.microsoft.com/scripting/understanding-the-six-powershell-profiles/
操作系统:Windows 10 Pro
另一个想法是在你的PATH中包含C:\Program Files\Sublime Text 2\,然后运行管理员命令提示符:
cd "C:\Program Files\Sublime Text 2\"
mklink sublime.exe sublime_text.exe
这将与新名称建立符号链接。现在你可以自由使用它了:
sublime hello.txt
更新:在有机会使用这个技巧并更新Sublime Text 2后,我很高兴地说更新到新的版本并不会影响符号链接。
将安装文件夹添加到windows路径,你将能够通过输入可执行文件的名称来打开Sublime,默认为“subl”。
要在windows路径中包含Sublime安装文件夹,
打开命令提示符并键入sysdm.cpl 在“高级”页签中选择“环境变量” 在“系统变量”下,选择名为“Path”的变量,单击“编辑”。 添加"C:\Program Files\Sublime Text;"到现有字符串的末尾。 保存更改并重新启动命令提示符。
Windows命令提示符
对于Windows cmd.exe,你可以添加崇高的文本安装目录到你的PATH环境变量,这将允许你输入:
sublime_text file.rb
就我个人而言,我添加了一个doskey(在.bat文件中设置为自动运行cmd),这样我就可以键入subl file.rb:
> doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*
Cygwin
对于默认的bash shell,为~/添加一个别名。Bashrc文件:
$ echo 'alias subl="/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe"' >> ~/.bashrc