【问题标题】:terminal command for running sublime text 3 from on ubuntu用于在 ubuntu 上运行 sublime text 3 的终端命令
【发布时间】:2015-06-10 16:50:42
【问题描述】:

我使用 Ubuntu 14.02 安装了一台新的开发机器。我还安装了所有相关软件。 php/apache2/sublime/composer 等

我希望能够在终端中使用 sublime 或 subl 命令打开文件,但似乎找不到正确指向内容的命令。

我的崇高可执行文件驻留在此处... /opt/sublime_text/sublime_text

在 /usr/bin/subl 我有命令

#!/bin/sh
exec /opt/sublime_text/sublime_text "$@"

我只是在终端中找不到实现它的命令。崇高的文档指向 mac 指令,但我太新了,无法翻译。

有什么建议吗?

【问题讨论】:

  • 您下载了压缩包吗?下载一个«.deb»包。 AFAIK 它安装在 $PATH /usr/bin/,似乎) 中的某个位置,因此无需在脚本中跳来跳去。至少我上次使用 Sublime 时是这样的(我去了 Emacs :Ь)
  • 看看stackoverflow.com/questions/12224904/…。运行 sublime(至少 sublime text2)时,您似乎可以只输入一个文件作为参数。
  • mattias.. 这正是我所需要的。找到了我正在寻找的一切。非常感谢。

标签: linux ubuntu terminal


【解决方案1】:

$@ 在 shell 脚本中基本上复制所有提供给 shell 脚本的参数(在脚本名称之后),并在脚本执行期间将它们放置在该点。

例如, 如果您要运行subl test.txt,就好像您正在运行exec /opt/sublime_text/sublime_text "test.txt"

现在,/opt/sublime_text/sublime_text --helpsubl --help 为我们提供了帮助文本,其中也显示了用法。

Sublime Text build 3065

Usage: sublime_text [arguments] [files]         edit the given files
   or: sublime_text [arguments] [directories]   open the given directories

Arguments:
  --project <project>: Load the given project
  --command <command>: Run the given command
  -n or --new-window:  Open a new window
  -a or --add:         Add folders to the current window
  -w or --wait:        Wait for the files to be closed before returning
  -b or --background:  Don't activate the application
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

Filenames may be given a :line or :line:column suffix to open at a specific
location.

如果你传递了多个参数,那么它们都被同样对待。因此,如果您运行 subl file1.txt file2.cpp file3.html,那么它将打开所有 3 个文件。

【讨论】:

    【解决方案2】:

    根据 Mathias 在我的问题中的评论,我在这里找到了答案...

    How can I open Sublime Text 2 files from the command line in linux to a tab, not a new window

    【讨论】:

      猜你喜欢
      • 2016-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-06
      • 2014-02-07
      • 1970-01-01
      • 1970-01-01
      • 2018-10-24
      相关资源
      最近更新 更多