Skip to content

Instantly share code, notes, and snippets.

View OdatNurd's full-sized avatar

Terence Martin OdatNurd

View GitHub Profile
@OdatNurd
OdatNurd / Context.sublime-menu
Last active March 17, 2023 06:03
Example plugin for encrypting and decrypting files from Sublime
[
{ "caption": "-", "id": "end" },
{ "command": "encrypt" },
]
@OdatNurd
OdatNurd / collect_versions.py
Created March 13, 2020 19:28
Collect minimum build version information for Sublime Text API endpoints
#!/usr/bin/env python3
import os
import ast
import glob
import zipfile
# Classes that are part of the API in general; the source files contain some
# helper classes that are just noise
_classes = [
# From the sublime module
@OdatNurd
OdatNurd / Default.sublime-keymap
Created May 2, 2020 04:42
Sublime Text Buzzword Lorem Ipsum
[
// Use our own buzzword lorem ipsum generator. It generates buzzword lorem
// using a rolling stock of 5 paragraphs and lets you generate multiple
// items at once.
{
"keys": ["tab"],
"command": "buzzword_ipsum",
"context": [
{ "key": "selection_empty", "operator": "equal", "operand": "true", "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^.*lorem\\d*$", "match_all": true },
@OdatNurd
OdatNurd / runInTerminal.sh
Created August 10, 2020 05:24
Execute arbitrary commands in Terminal on MacOS
#!/bin/sh
osascript - "$@" > /dev/null <<SCRIPT
on run argv
set originalTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to space
tell application "Terminal"
activate
set newTab to do script(argv as text)
[
{ "caption": "Input Handlers: Sample 1", "command": "example_one" },
{ "caption": "Input Handlers: Sample 2", "command": "example_two" },
{ "caption": "Input Handlers: Sample 3", "command": "example_three" },
{ "caption": "Input Handlers: Sample 4", "command": "example_four" },
{ "caption": "Input Handlers: Sample 5", "command": "example_five" },
{ "caption": "Input Handlers: Sample 6", "command": "example_six" },
]
@OdatNurd
OdatNurd / Sample Build.sublime-build
Last active September 9, 2020 18:28
Sample plugin for allowing you to select what Makefile to use for a build
{
"target": "makefile_build",
"cancel": {"kill": true},
"shell_cmd": "make -f \\${selected_makefile}",
"file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "\\${selected_makefile_path}",
"selector": "source.makefile",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",
@OdatNurd
OdatNurd / Default (Windows).sublime-keymap
Created November 9, 2020 07:21
Setting up a Python REPL in Sublime Text using Terminus
[
// Place the bindings in your user Key bindings for whatever platform you're
// on (also, change the keys as appropriate for your use).
// Send a newline to the Terminus Python REPL, if it's open
{ "keys": ["shift+ctrl+enter"], "command": "terminus_send_string",
"args": {"string": "\n", "tag": "python-repl"},
"context": [
{ "key": "terminus_tag.exists", "operand": "python-repl" },
{ "key": "selector", "operator": "equal", "operand": "source.python" },
@OdatNurd
OdatNurd / .python-version
Last active July 8, 2024 03:37
Browse all Sublime Text commands provided by plugins
3.8
@OdatNurd
OdatNurd / key_context_example.py
Created November 19, 2020 19:00
Defining a custom settings key context for Sublime Text that can compare any setting and not just booleans
import sublime
import sublime_plugin
class CustomContextEventListener(sublime_plugin.EventListener):
"""
This event is raised when Sublime sees a key binding context key it does not
recognize.
"""
def on_query_context(self, view, key, operator, operand, match_all):
@OdatNurd
OdatNurd / view_tests.py
Created December 14, 2020 07:59
Plugin example: How to work with Points and Regions in Sublime Text
import sublime
import sublime_plugin
class RegionExampleCommand(sublime_plugin.TextCommand):
def run(self, edit, example):
if example == "1": region = sublime.Region(0, 10)
elif example == "2": region = sublime.Region(10, 20)
elif example == "3": region = sublime.Region(5)
elif example == "4": region = self.view.word(5)