browse

Adds commands that let you quickly browse Atom-related folders or reveal files you're working on

idleberg

81,135

5

Bug Reports

3.8.0

MIT

GitHub

This package provides the following services:

browse

apm apm apm CI David

Description

Adds commands that let you quickly browse Atom-related folders or reveal files you're working on (details below)

Screenshot

Installation

apm

Install browse from Atom's Package Manager or the command-line equivalent:

$ apm install browse

Using Git

Change to your Atom packages directory:

Windows

# Powershell
$ cd $Env:USERPROFILE\.atom\packages
:: Command Prompt
$ cd %USERPROFILE%\.atom\packages

Linux & macOS

$ cd ~/.atom/packages/

Clone the repository as browse:

$ git clone https://github.com/idleberg/atom-browse browse

Install dependencies:

$ cd browse && npm install

Usage

Once installed, you can run any of the following commands from the Command Palette.

Project-specific:

Atom-specific:

Settings

If you want to override your system's default file-manager, you can specify its path in the package settings.

Example
browse:
  customFileManager:
    fullPath: "%PROGRAMFILES%\\Explorer++\\Explorer++.exe"

Furthermore, you can specify custom arguments for the open and reveal actions.

Example
browse:
  customFileManager:
    openArgs: ["-o", "%path%"]
    revealArgs: ["-r", "%path%"]

Note: The %path% placeholder can be omitted when it's the last argument

Service Provider

API

At its most basic, the method provided by the service accepts a single argument, the path to a file or folder:

browse(pathToFile);

However, you can also pass an object that offers additional options:

browse({
  action?: "reveal",
  message?: "Revealing output file..."
  silent?: false,
  target: pathToFile
})

See below for a real-world example.

Usage

To consume the provided service, add the following to your package.json:

{
  "consumedServices": {
    "browse": {
      "versions": {
        "1.0.0": "consumeBrowse"
      }
    }
  }
}

Next up, you need to consume the service in your package's main file.

Example
import { CompositeDisposable, Disposable } from "atom";

export default {
  // Assign service provider
  consumeBrowse(browse) {
    this.browse = browse;

    return new Disposable(() => {
      this.browse = null;
    });
  },

  // Example function that consumes the service
  async revealFile(pathToFile) {
    await this.browse(pathToFile);
  },

  // Optional: Assign command for your reveal function
  activate() {
    this.subscriptions = new CompositeDisposable();

    this.subscriptions.add(
      atom.commands.add("atom-workspace", {
        "my-package:reveal-file": async () =>
          await this.revealFile("/path/to/file"),
      })
    );
  },
};

Options

action

Type: string
Arguments: reveal | open

Specifies the default action for the service. You can open folders or reveal files in your file manager.

Note: As of version v3.1, this option can be omitted. The action will then be determined by whether target option resolves to a file or directory.

target

Type: string | string[]

Specifies the target path(s) that should be opened.

message

Type: string

Custom message to be displayed for the action

silent

Type: boolean

Disables notification for action

License

This work is licensed under the MIT License