July 2019 - UI39

Archive Monthly Archives: July 2019

sublime-text

Launch Sublime Text From The Command Line

OS X Command Line

Sublime Text includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text, as well working as an EDITOR for unix tools, such as git and subversion.

Setup

The first task is to make a symlink to subl. Assuming you’ve placed Sublime Text in the Applications folder, and that you have a ~/bin directory in your path, you can run:

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Usage

Run subl --help,

Usage: subl [arguments] [files]         edit the given files
   or: subl [arguments] [directories]   open the given directories
   or: subl [arguments] -               edit stdin

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
  -s or --stay:        Keep the application activated after closing the file
  -h or --help:        Show help (this message) and exit
  -v or --version:     Show version and exit

--wait is implied if reading from stdin. Use --stay to not switch back
to the terminal when a file is closed (only relevant if waiting for a file).

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

EDITOR

To use Sublime Text as the editor for many commands that prompt for input, set your EDITOR environment variable:

export EDITOR='subl -w'

Specifying -w will cause the subl command to not exit until the file is closed.

Ubuntu Command Line

sudo ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl

Windows Command Line

I added this to my PowerShell profile:

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

To include the Sublime installation folder in windows path,

  1. Open command prompt and type sysdm.cpl
  2. In Advanced tab, select Environment variables
  3. Under system variables, select variable named “Path” and click Edit.
  4. Add “C:\Program Files\Sublime Text 3;” to the end of the existing string.
  5. Save the changes and restart command prompt
sublime-git

Git Client with Sublime

Meet a new Git Client, from the makers of Sublime Text

A snappy UI, three-way merge tool,
side-by-side diffs, syntax highlighting, and more.
Evaluate for free – no account, tracking, or time limits.
Interested? Read the release announcement.

Feature Highlights

INTEGRATED MERGE TOOL

The Integrated Merge Tool allows you to resolve any merge conflicts directly in Sublime Merge, rather than having to open up your editor of choice.

Conflicts are presented with a 3-pane view. On the left are your changes and on the right are theirs. In the center pane is the resolved text, with buttons to choose between your changes or theirs. The same text editing functionality as Sublime Text is also available for more complicated merges.

Clicking on the header in the middle pane will switch between the editable merge results and the base file.

Use +S or the Save button to save your merged file.

POWERFUL SEARCH

Use find-as-you-type search to dig up the exact commit you’re looking for.

Search for commit messages, commit authors, file names, and wildcard patterns. Complex search queries can be constructed using andor and () symbols.

For example min-parents:2 author:jskinner path:tests/* (bug fix or test) will search for a merge commit from jskinner inside the tests directory that contain the words “bug” and “fix” or the word “test”.

You can open search with +F or through the menu: Navigate ▶Search.

UNMATCHED PERFORMANCE

Sublime Merge is built on the same custom platform as Sublime Text, providing unmatched responsiveness. With a powerful, cross-platform UI toolkit, an unmatched syntax highlighting engine, and a custom high-performance Git reading library, Sublime Merge sets the bar for performance.

BLAME

Open the Blame of a file through the Command Palette or when viewing a commit to see exactly which lines of the file were added by which commits.

Easily view the age, author, and commit hash of every line of code and see which lines come from the same commit with our commit color coding. Click a line in the gutter to highlight all other lines from the same commit.

The blame tool will also detect when a piece of code was moved from another place in your repository, so you can truly follow the history of your code.

ADVANCED DIFFS

Where it makes sense we will show you exactly which individual characters have been changed for a commit.

This includes when you rename or move a file, when you’re resolving conflicts or just viewing commit history.

Select any two commits in Sublime Merge with +Left Mouse to show the diff between them.

FILE AND HUNK HISTORY

From any file or hunk in the history use … ▶ File History or the Hunk History button to view the full history of that source code. This will also follow any file moves or renames throughout the repository.

COMMAND PALETTE AND KEY BINDINGS

Keyboard usage is important to us. Use Tab to navigate through parts of the application, Space to toggle expansion, and Return to stage/unstage hunks. When writing a commit message, use +Return to commit.

The Command Palette is triggered by +P and allows quick access to a large set of Git commands as well as other Sublime Merge functionality.

LIGHT AND DARK THEMES

Choose between a light and a dark theme to suit your tastes. You can preview these themes above.

Open the Preferences ▶ Preferences… menu to change theme.

The dark theme is only available with a valid license key.

EXTENSIBILITY

Just like Sublime Text, just about everything in Sublime Merge is extensible. Key bindings, menus, theming, and the command palette are all customizable with simple JSON files.

SYNTAX HIGHLIGHTING

Sublime Merge performs full syntax highlighting identically to Sublime Text for every line of code you see.

We’ll even use any extra syntax definitions that we find in your Sublime Text installation for syntax highlighting!

COMMAND LINE INTEGRATION

Sublime Merge is designed to work hand in hand with the command line. All changes to the repository are updated live and everything works the same way whether it’s triggered from the command line or the UI. Use the terminal where it makes sense and use the GUI where it works best.

Use the smerge tool that comes with Sublime Merge to interact with it from the command line: open repositories, blame files or search for commits

REAL GIT

Sublime Merge uses the same terminology as Git, and doesn’t make use of any state beyond Git itself. When you’re working with Sublime Merge, you’re working with Real Git, not a simplified version

You can also hover over most buttons to see which git command it will run.