npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@techrah/text-shortcuts

v1.0.4

Published

Insert text via shortcut keys in Jupyter Lab.

Downloads

149

Readme

text-shortcuts

A jupyterlab extension to insert text via keyboard shortcuts.

release

Pre-requisites

Installation

jupyter labextension install @techrah/text-shortcuts

or add it through your Jupyter Lab Extensions tab.

Then, add some user shortcuts:

  • In Jupyter Lab, select Settings / Advanced Settings Editor from the menu.

  • Select the Keyboard Shortcuts tab.

  • In the User Preferences section, add your shortcuts configuration and click the "save" icon.

Here are two useful shortcuts for programming in R:

{
    "shortcuts": [
        {
            "command": "text-shortcuts:insert-text",
            "args": {
                "kernel": "ir",
                "text": "|>",
                "autoPad": true
            },
            "keys": ["Accel Shift M"],
            "selector": "body"
        },
        {
            "command": "text-shortcuts:insert-text",
            "args": {
                "kernel": "ir",
                "text": "<-",
                "autoPad": true
            },
            "keys": ["Alt -"],
            "selector": "body"
        }
    ]
}

NOTE: As of version 0.1.x You do NOT need to add the above shortcuts to User Preferences unless you want to override the default behaviour. These two shortcuts are now installed by default. They can be found in Keyboard Shortcuts / System Defaults.

Anatomy of a Text Shortcut

{
    ...
    "command": "text-shortcuts:insert-text"
    ...
}

Identifies the keyboard shortcut as a text shortcut that is intercepted by this extension.

{
    ...
    "keys": [
        "Accel Shift M"
    ],
    ...
}

keys is an array of keyboard shortcuts that activate the insertion of the text snippet. Each entry can be a combination of one or more of the following modifiers, ending with a text character. For example, "Accel Shift M" represents Command-Shift-M on macOS.

  • Accel : Command (macOS) / Ctrl (Windows)
  • Alt : Option (macOS) / Alt (Windows)
  • Shift : Shift
  • Ctrl : Control
{
    ...
    "args": {
        "kernel": "ir",
        "text": "|>",
        "autoPad": true
    }
    ...
}
  • kernel (optional): If you specify a kernel, the shortcut will only work in notebooks that are running the specified kernel. Examples of kernel names are ir and python3. For a list of installed kernels, use jupyter kernelspec list.

  • text: This is the actual text that you want inserted.

  • autoPad: (true | false). If true, will add spacing either before, after, or both before and after so that there is a single space on each side of the text.

{
    ...
    "selector": "body"
    ...
}

CSS selector. Always use "body" for this extension.

Development

Pre-requisites

  • node 5+
  • Python 3.6+

It is strongly recommended that you set up a virtual Python environment. These instructions will assume that Anaconda is already installed.

  • Create a new virtual environment and activate it.

    conda create --name text-shortcuts
    conda activate text-shortcuts
  • Install jupyterlab

    conda install jupyterlab
  • Clone this project and in the root of the project folder, install dependencies with the JupyterLab Package Manager

    jlpm
  • Install the extension

    jupyter labextension install . --no-build
  • Start up jupyter lab in watch mode. Don't forget to activate your virtual environment. If you want to use a different browser for development, specify that with the --browser switch. If you want to use a custom port, specify that with the --port switch.

    conda activate text-shortcuts
    jupyter lab --watch --browser="chrome" --port=8889
  • In another terminal, run the TypeScript compiler in watch mode.

    conda activate text-shortcuts
    jlpm tsc -w

For more information on developing JupyterLab extensions, here are some helpful resources:

Pull requests are welcome!