subl
Open files or directories in Sublime Text
TLDR
Open the current directory in Sublime Text
Open a file or directory in Sublime Text
Open a file and jump to a specific line number
Open a file or directory in the currently open window
Open a file or directory in a new window
SYNOPSIS
subl [options] [file(s):line_number] [directory(s)]
PARAMETERS
-h, --help
Show help message and exit.
[file(s):line_number]
Open the specified file(s) at the specified line number. If no line number is given, the file opens at the beginning.
Example: subl myfile.txt:10
[directory(s)]
Open the specified directory(s) in Sublime Text as project folders.
--project
Load the given project.
-n, --new-window
Open a new window of Sublime Text.
-a, --add
Add the given file(s) or directory(s) to the current window.
-w, --wait
Wait for the files to be closed before returning. Useful when using subl as a `git commit` editor.
--safe-mode
Start with safe mode and disable plugins (new in 4127).
--command
Run the given command.
DESCRIPTION
The `subl` command is a utility that allows you to open files and directories in Sublime Text from the command line. It provides a convenient way to quickly edit files, start new projects, or navigate existing ones directly from your terminal. Instead of manually opening Sublime Text and navigating to the desired file, `subl` streamlines the process, improving workflow efficiency. It is typically included in the Sublime Text installation package. The command supports opening single files, multiple files, or entire directories. It also allows you to specify a line number to position the cursor within a file when it opens. Furthermore, `subl` integrates with the Sublime Text project system, enabling you to open existing projects and manage project-specific settings directly from the command line. This command is a wrapper over the sublime application, so it uses the sublime configuration and installed packages.
CAVEATS
The `subl` command relies on Sublime Text being properly installed and the `subl` executable being in your system's PATH environment variable. You need to manually create a symbolic link to the sublime_text executable, usually located in the /opt directory (e.g., `sudo ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl`). Without this link, the command will not be found.
ENVIRONMENT VARIABLES
The EDITOR environment variable can be set to 'subl -w' to use Sublime Text as your default editor in other command-line tools that respect this variable (e.g., Git, Mercurial).
GIT INTEGRATION
Using `subl -w` with Git allows Sublime Text to function as a text editor to create commit messages.