Giter Site home page Giter Site logo

sm11963 / xcodeuniversalsearch Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 4.54 MB

An Xcode source editor extension to provide custom search urls, just like custom search engines for a browser.

License: MIT License

Swift 40.98% Objective-C 58.70% C 0.23% CSS 0.09%
source-editor-extension xcode-extension swift xcode search

xcodeuniversalsearch's Introduction

XcodeUniversalSearch

License: MIT

Add shortcuts to search any url with selected text. This is like custom search engines for Google Chrome, for Xcode. We use it to quickly search Sourcegraph directly to link code to documentation and share with co-workers.

Example configuration UI screenshot

Instructions

Install

  1. Download DMG from Releases.
  2. Open DMG.
  3. Drag the app into the Applications directory.
  4. Launch the app.
  5. (optional) Add/remove search urls as desired, you can always do this later.
  6. Open System Preferences > Extensions > Xcode Source Editor, make sure that UniversalSearch is enabled.
  7. If open, quit Xcode.

Use the extension

  1. Launch Xcode.
  2. Select some text in the editor (this must be on a single line right now).
  3. Go to Menu bar > Editor > XcodeUniversalSearch (at the bottom) and select an option to open your defined URL with the selection.

Editing configuration

  1. Open XcodeUniversalSearch application.
  2. Add/delete/update your search commands as necessary.
    • The Command name is what shows up in the Editor menu.
    • When the command is selected, the selected text is filled into the URL template replacing any %s tokens, the resulting URL is launched.
    • In Options, you can configure additional logic for constructing the URL, see Options for more details.

Options

For each URL, there are some additional options to configure how to construct the URL to open.

Remove percent encoding from url template and encode final url

Default enabled

This configures if the full URL should be percent encoded before opening the URL. In order to be make it easier to copy and paste URLs, before percent encoding, this option will decode any existing percent encoded characters in the URL template. This should work most of the time, but there may be cases where this could cause some issues. If disabled, you will need to make sure that the URL template is appropriately percent encoded as a URL.

Note, the selected text will always be percent encoded regardless of this option - this option only affects the URL template.

Escape regex metacharacters in search string (escaped with /)

Default disabled

Enables escaping characters in the selection text that might match regex metacharacters. This is done using NSRegularExpression.escapedPattern(for:), checkout those docs for an example of what this does.

This is useful if searching in a Sourcegraph regex pattern, typically your search from the selected text should be literal see the "Sourcegraph type" url template in the screenshot.

Escape double quotes in search string (escaped with /)

Default disabled

Enables escaping double quotes in the selection text.

This is useful if searching with a query which requires wrapping in double qoutes. For example, see "Sourcegraph literal" url template in the screenshot.

Export / Import configuration

You can export and import your configuration as a JSON file. This allows you to backup or share your configurations. For example, the configuration used in the screenshot is this example_config.json.

Setup key bindings

  1. Launch Xcode.
  2. Open Xcode > Preferences > Key Bindings.
  3. Search for "XcodeUniversalSearch".
  4. Double click on the "Key" column next to the command for which to add a shortcut.
  5. Press your chosen shortcut keys.
  6. Click somewhere in the preferences pane, other than the "Key" column to save your key binding.
  7. Make sure to check for conflicts with your shortcut (shown on the footer of the preference panel while setting shortcuts and also in the Conflicts tab).
  8. Use your shortcut while editing.

Recommended shortcuts

Command Shortcut
Literal search for seletion ⌥s (Option-s)
Search for Swift type with selected name ⌥⇧S (Option-Shift-S)
Search for file with selected text ⌥f (Option-f)

TODO

See Issues for TODOs and bugs.

Assets

All assets can be found in this XcodeUniversalSearch Figma (only the app icon right now).

Attributions

  • We use a replication of krzysztofzablocki/Versionable to make our models versionable.
  • The magnifying glass asset used in the app icon is sourced from pngwing (non-commercial use license).

xcodeuniversalsearch's People

Contributors

sm11963 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

commanderpho

xcodeuniversalsearch's Issues

Handle and report errors

Display / log errors better (lots of errors just print now).

It would be nice to display users an error message, optionally with a code so that errors can be reported. Also, making it easy to report any error logs would also be great.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.