Skip to content

Instantly share code, notes, and snippets.

@matvore
Created December 13, 2024 16:18
Show Gist options
  • Select an option

  • Save matvore/0feb4721147464f340fe86a234e85117 to your computer and use it in GitHub Desktop.

Select an option

Save matvore/0feb4721147464f340fe86a234e85117 to your computer and use it in GitHub Desktop.
var numpadremap = [
[/[0-9] /, {'!': '1', '@': '2', '#': '3', '$': '4', '%': '5', '^': '6', '&': '7', '*': '8', '(': '9', ')': '0',
'1': '!', '2': '@', '3': '#', '4': '$', '5': '%', '6': '^', '7': '&', '8': '*', '9': '(', '0': ')',
}],
];
// test
window.extended_macros.connom = [
['laL E ', function ()
{
navigator.clipboard.readText()
.then(function(ct)
{
var m = ct.match(/:(\d+)(:|$)/), len, ext='',
fn;
if (!m) {len=ct.length}
else {len=m.index; ext=`+${m[1]} `}
fn = ct.substr(0, len);
signal(`\\t${sanit(fn)}\n`);
signal(sanit(`less ${ext}${fn}\n`));
});
}],
['laN O ', function ()
{
window.open('/?termid=notes.' + termid.split('.')[0]);
}],
['laU 1 6 ', ' | iconv -t utf-16be | xxd\001printf '],
['laN V P ', '/usr/share/novnc/utils/novnc_proxy '],
['raB Y M ', ' --author=matvore '],
['rarsE ', function() { set_locked_title('c');
signal('\\n export vf; vim -nC $vf\\n');
}],
['la; H ', '\x1b:e $vf\n'],
['raV W F ', 'echo $vf\n'],
['laJ L ', '\014'],
['la. D N ', '>/dev/null'],
['laE ', 'vim -nC '],
['raZ G ', 'TZ=UTC git '],
['ra` ', 'HEAD~'],
['raR I B ', 'TZ=UTC git rebase -i basedon'],
['laI U ', '|perl -pE\'s/^(\\d{8,10}) //; $_=`date -d\\@$1 +"%F %T %Z"`." $_"; s/\\n//; s/\\b(...)[0-9a-f]{37}\\b/$1/g; s/\\[(...\\])/[ $1/\'|less\x01git log --full-history --format="%ct [%P] %h %s" '],
['raR I O ', 'TZ=UTC git rebase -i origin/main '],
['raF E = ', ' -exec {} +\001find '],
['raC ', function() { capsonwhile = /[A-Z0-9] |ls|rs|- |bs|me/; }],
['la#l', function() { remap_keys = remap_keys.length ? [] : numpadremap; }],
['laM N E ', ' TZ=UTC git commit --amend --no-edit '],
['laI C F H ', ' TZ=UTC git commit --fixup=HEAD~'],
['lalsI C M ', function()
{
function siggarb(amt)
{
var b = new Uint16Array(amt), x;
crypto.getRandomValues(b);
function from5bits(no)
{
no &= 0x1f;
if (no < 26) no += 97;
else no += 48 - 26;
return String.fromCharCode(no);
}
b.forEach(function(v)
{
signal(from5bits(v));
signal(from5bits(v >> 5));
signal(from5bits(v >> 10));
});
}
signal('TZ=UTC git -c user.email=');
siggarb(2);
signal('@');
siggarb(2);
signal(' -c user.name=');
siggarb(4);
signal(' commit -m ');
siggarb(4);
signal(' ');
}],
['lavsL ', ' 2>&1 | less\r'],
['raG F S ', "git status -s -uno | sed \'s,..,"],
['raD F N ', 'git diff --name-only HEAD~'],
['laI F ', 'git status -s -uno\r'],
['laI R V ', 'git remote -v\r'],
['laI lsF ', 'git status -s -uall\r'],
['laI D ', 'git diff '],
['laI L ', ' | sed \'/^Author\\(Date\\)*:/d; /^Commit:/!b; N; s/\\nCommitDate:/ --/; s/^[^<]*//\' | less -R\001git log --decorate --color=always --pretty=fuller --date=iso-local --name-status '],
// ['laI L ', 'git log --name-status '],
['laI C O ', 'git checkout '],
['laI C D ', 'git diff --cached '],
['laI B R ', 'git branch '],
['laI C M ', ' TZ=UTC git commit '],
['laI S ', 'git show '],
['laI P L ', 'git pull '],
['raS B L ', '\001 seq 100; '],
['laI T ', '|perl -pE\'/^([^0-9]*)(\\d{8,10})\\b(.*)/ and $_=$1.`date -d\\@$2 +"%F %T %Z"`."$3\\n" and s/\\n//\'|less \x01git log --graph --format="%ct %h %s" '],
];
if (termid && termid.endsWith('.notes'))
window.extended_macros['notes'] = [
['raG O ', 'cd ~/n/' + termid.split('.')[0]],
];
wermcfg.pass_ctrl_L = 1;
deadkey_map[0][1] = ')';
deadkey_map[1][1] = '(';
deadkey_map[2][1] = '"';
deadkey_map[3][1] = '$';
menu_key_inserts = '_';
// range of --date flag for git commit: 100000000 to 2^31-1
wermcfg.basic_git_macros = 0;
if (clientInformation.platform == 'Win32') set_default_font(4);
show_barrier(80);
extended_macros['nvim'] = [
['raD L N V ', '/nvim-linux64.tar.gz | tar -C ~/.local -zxvf - # e.g. 0.10.0\001curl -L https://github.com/neovim/neovim/releases/download/v'],
['laN V ', function()
{
set_locked_title('c');
signal('\\n export vf; ~/.local/nvim-linux64/bin/nvim -n $vf\\n');
}],
];
if (localStorage['deffont']) set_default_font(Number(localStorage['deffont']));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment