Skip to content

Instantly share code, notes, and snippets.

@Screwtapello
Screwtapello / termcolors.sh
Created March 26, 2012 04:04
Which are the bright terminal colours?
#!/bin/bash
get_color_from_palette() {
# Query the terminal for the current value of a palette entry.
# Prints three decimal numbers from 0-65535 representing the red, green and
# blue components of the given palette entry.
local paletteNum="$1"
# This function only works in xterm and (some) derivatives
if [ "${TERM:0:5}" != "xterm" ]; then
#!/usr/bin/python
import sys
import os
import re
from xml.etree import ElementTree as ET
SAVE_TYPE_RE = re.compile(r"""
EEPROM_V\d{3} |
SRAM_V\d{3} |
SRAM_F_V\d{3} |
@Screwtapello
Screwtapello / Firebrand-X-NES-Saturated.gpl
Created January 1, 2016 03:15
FirebrandX's Final NES Composite Palette
GIMP Palette
Name: FirebrandX NES Saturated
Columns: 4
#
255 255 255 White 1
255 255 255 White 2
178 178 178 White 3
107 107 107 White 4
187 227 254 Blue 1
83 172 253 Blue 2
! /* <-- A hack to stop xrdb from reading this file
# Behaviour changes
XTerm*saveLines: 10000
XTerm*scrollTtyOutput: false
XTerm*scrollKey: true
XTerm*scrollBar: false
XTerm*metaSendsEscape: true
XTerm*VT100.Translations: #override \
aaabaaabaaa
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Screwtapello
Screwtapello / path.rs
Last active June 15, 2018 04:01
Monotonic path implementation for Rust
//! Cleaned-up cross-platform path handling
//!
//! Most operating systems accept a complex syntax for specifying filesystem
//! paths, including special notation for things like "the current directory"
//! and "the parent directory" that make path-handling code intricate. If
//! filesystem paths always described a straight-line path from the root to
//! the file or directory in question, path-handling code could be much simpler.
//!
//! This module contains types representing exactly those kinds of paths.
//!
# Readline has a bunch of special-case bindings just for vi mode, which means we
# can't just add Kakoune-style bindings; instead, we must build Kakoune-style
# bindings from combinations of other (usually emacs-based) commands. BUT
# Readline doesn't support binding a key to a sequence of commands; instead,
# we bind commands to a likely-unused portion of the keymap, and then bind
# our actual keys to sequences of those unusual keys.
"\C-a\C-xm": set-mark
"\C-a\C-xh": backward-char
"\C-a\C-xl": forward-char
"\C-a\C-xw": forward-word
declare-option -hidden int last_state_save_history_id 0
declare-option str state_save_path %sh{
echo ${XDG_DATA_HOME:-~/.local/share/}/kak/state-save/
}
define-command \
-docstring "Save the current selection state for this file" \
state-save \
%{ evaluate-commands %sh{
@Screwtapello
Screwtapello / tree-custom.kak
Created December 29, 2018 20:50
Mappings for kak-tree
declare-user-mode tree
map -docstring "prev" global tree <left> ": tree-select-prev-node<ret>"
map -docstring "parent" global tree <up> ": tree-select-node<ret>"
map -docstring "next" global tree <right> ": tree-select-next-node<ret>"
map -docstring "children" global tree <down> ": tree-select-children<ret>"
hook global WinSetOption filetype=.* %{
evaluate-commands %sh{
if command -V kak-tree >/dev/null 2>/dev/null &&