dxshank / open-url

Open URLs, files, folders, or google text under the cursor or in selected text for Sublime Text.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Open URL

Description

Quickly open files, folders, or web URLs from anywhere in Sublime Text.

Install

Look for Open URL using the Package Manager

How to use

Put the cursor inside a file / folder / URL / word and run the command. It automatically expands the selection until it hits delimiter chars, which can be changed in the settings (see below).

Alternatively, highlight the text you want to open. If text is highlighted the selection is not expanded.

Here's a bunch of ways you can run the command.

  • ctrl+u
  • right-click > Open URL
  • alt + double-click
  • shift+cmd+p, then look for Open URL

Give it a try

Copy the items below to Sublime Text. Place your cursor inside any one of them and hit ctrl+u.

How does it work?

If your selection is a file or a folder, you can choose to edit it (open with Sublime Text), or reveal it (open with macOS Finder/Windows File Explorer/Linux File Manager).

Opening files and folders is super convenient. Both can be specified with absolute paths, paths relative to the currently open file, or paths relative to the root of the currently open project. Env vars and the alias ~ are expanded.

If your selection is a URL, it opens immediately in a new tab in your default web browser. You can omit the scheme (http://) if you want and Open URL will add it for you.

If your selection is none of the above, you'll be presented with two options:

  • modify the selection and try again
  • search for the selection using one of your configured web_searchers
    • the only web searcher that ships with Open URL is Google search
    • to add others, read more in the "Settings" section below

Shortcuts

Don't want to choose from menu items to open a file or a folder? Look for Open URL (Skip Menu) in the Command Palette. To create a key binding for this, open Preferences: Key Bindings from the Command Palette, and add the following:

{ "keys": ["your+key+binding"], "command": "open_url", "args": { "show_menu": false } },

This will open files in Sublime Text for editing, or reveal folders in the Finder, without showing the menu first.

Running commands on files or folders

Open URL provides a few settings you can configure to run custom commands on files or folders:

  • folder_custom_commands
  • file_custom_commands
  • autoactions

Read more below.

Settings

To customize these, hit shift+cmd+p to open the Command Palette, and look for Open URL: Settings.

  • delimeters
    • characters at which auto-expansion of selected path stops, e.g. \t\n\r\"',*<>[]()
    • the default settings are Markdown friendly
  • trailing_delimiters
    • if any of these characters are seen at the end of a web URL, they are recursively removed; default is ;.:
  • web_browser
    • the browser that Open URL uses to open new tabs; must be a string from this list
    • if you use an empty string, the "default browser" will be used
    • if you choose a browser that's not installed on your machine, Open URL will complain
  • web_searchers
    • if your selection isn't a file, a folder, or a URL, you can choose to pass it to a web searcher, which is just a URL that searches for the selected text
    • example: { "label": "google search", "url": "http://google.com/search?q=", "encoding": "utf-8" }
  • file_custom_commands
    • pass a file to any of these shell commands, run in a subprocess
  • folder_custom_commands
    • pass a folder to any of these shell commands, run in a subprocess
    • example: { "label": "open in terminal", "commands": [ "open", "-a", "/Applications/iTerm.app" ] }
  • folder_extra_commands
    • set to this to false if you want to disable the following folder commands: ('add to sublime project', 'new sublime window')
  • file_extra_commands
    • set to this to false if you want to disable the following file commands: ('run', 'new sublime window', 'system open')
  • autoactions
    • you can set specific file extensions to be edited or run without having to choose from any options
    • if the action is edit it will be opened for editing in Sublime Text
    • if the action is run it will be executed by the OS
    • you add an 'openwith': 'myprogram.exe' to specify a specific a program to open the file with
      • in this case the shell will execute the openwith program and the selection will be a parameter

Finally

See also: Google Spell Check.

Credits: Thanks goes to peterc for starting a forum thread about this topic and KatsuomiK for his gist, which were the inspiration for this plugin.

Author: @noahcoad writes software for the heck of it and to make life just a little more efficient.

Maintainer: @kylebebak.

About

Open URLs, files, folders, or google text under the cursor or in selected text for Sublime Text.

License:MIT License


Languages

Language:Python 100.0%