ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Token Generator

by pxninja ALL

Generate random, alpha-numeric tokens within Sublime Text.

Details

  • 1.0.3
  • github.​com
  • github.​com
  • 4 months ago
  • 11 minutes ago
  • 4 months ago

Installs

  • Total 13
  • Win 8
  • Mac 5
  • Linux 0
Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Token Generator

A Sublime Text package that lets you generate new / random / five character / alpha-numeric strings with a hotkey, from the context menu (right clicking), or from the Command Palette.

Example output: a1b2c

Installation

Package Control

If you have Package Control installed: 1. In Sublime Text, open the Command Palette by typing Command+Shift+P (Mac) or Ctrl+Shift+P (Linux / Windows). 2. Type install and select Package Control: Install Package 3. A text prompt should appear shortly after Package Control loads a list of packages from the internet. 4. Type token generator and press Enter 5. That's it! The token generator is now installed.

Manual Download

  1. Click here to download the GitHub repository, and unzip the downloaded file.
  2. In Sublime Text, open the Command Palette by typing Command+Shift+P (Mac) or Ctrl+Shift+P (Linux / Windows).
  3. Type browse and select Preferences: Browse Packages
  4. A window should appear with the “Packages” directory selected. Move the unzipped file into the “Packages” directory.
  5. That's it! The token generator is now installed.

Usage

Once Installed, you will be able to create new / random / five character / alpha-numeric tokens in 1 of 3 ways: 1. Keyboard Shortcut: Command+Option+Shift+T (Mac) or Ctrl+Alt+Shift+T (Linux / Windows). 2. Context Menu: right click within Sublime Text and select New Token. 3. Command Palette: open the Command Palette, type new token, and select Token Generator: New Token

By default, the Keyboard Shortcut option is disabled. To enable the Keyboard Shortcut, open the Command Palette, type key binding and select Token Generator: Key Binding.

By default, the Context Menu option is enabled. To disable the context menu option, open the Command Palette, type settings and select Token Generator: Settings.

The Command Palette option is always available.

Settings

There are 4 settings:

  1. String Length, 5 by default
  2. Character Set, abcdef0123456789 by default (aka. hexadecimal / base-16)
  3. Force alpha numeric inclusion, true by default (aka. ensures string has at least 1 letter and 1 number)
  4. Show in context menu, true by default (aka. it will be available in the context menu)

There are 940,800 unique tokens with these settings (165 - 105 - 65). This is more than sufficient for the intended purpose. Don't go generating passwords with these settings.

To change these settings, open the Command Palette, type token settings and select Token Generator: Settings. Edit the settings as you would any other Sublime Text feature.

But … why?

Short randomized tokens are useful in a variety of contexts. The inspiration for this plugin was to help with CSS specificity issues. Notably to…

  1. Mitigate name space collisions
  2. Improve style management

Appending tokens to the end of an id or class name helps ensure uniqueness without silently breaking previous styles. No more name space collisions!

Creating a new id or class name? Easily append a unique token using the hot key (or right clicking) and .btn becomes .btn-a1b2c.

Want to find each instance of an existing style? In Sublime Text, type Command+Shift+F (Mac) or Ctrl+Shift+F (Linux / Windows) to find where btn-a1b2c lives in your project. Good luck finding / editing the correct btn style!

Naturally this raises questions around tree shaking. Want keep your style sheet from bloating? When you append unique tokens to id / class names (effectively treating them like GUIDs) you can delete the useless bits without silently breaking stuff.

All of this is to say: this Sublime Text plugin makes random token generation convenient, supporting better CSS management (among other use cases). No more copy / pasting from some other list of random tokens, or Googling for a generator. Now you can get a fresh token without ever leaving your code.

License

MIT License