Skip to content

Instantly share code, notes, and snippets.

@geraldlai
geraldlai / grec
Created October 15, 2019 21:14
grec: grep grep-context
#!/usr/bin/env perl
# grec: grep grep-context
# $ grep -C 5 foo * | grec grep bar
# ( grep 'bar' from contextual output with 'foo' while maintaining context )
# ( grec understands grep, rg, and ag )
# Author: Gerald Lai
# License: 0BSD
# remap prefix
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
# 0 is too far
set -g base-index 1
setw -g pane-base-index 1
# vi bindings for copy mode
@geraldlai
geraldlai / git-commit-fix
Last active May 2, 2024 21:55
git commit-fix: fixup an old commit quickly
#!/usr/bin/perl
# git commit-fix: fixup an old commit quickly
# $ git commit-fix 1efa604
# ( fixup commit 1efa604 to have currently staged changes )
# ( unstaged changes will be safely stashed away )
# $ git commit-fix -s 1efa604
# ( same as above, but allow new commit message to be squashed in )
@geraldlai
geraldlai / snuff
Created February 5, 2019 23:21
snuff: kill processes gracefully
#!/usr/bin/perl
# snuff: kill processes gracefully
# Author: Gerald Lai
# License: 0BSD
use warnings;
use strict;
@geraldlai
geraldlai / wgrep
Created September 5, 2018 03:54
wgrep: write grep output back as changes
#!/usr/bin/perl
# wgrep: write grep output back as changes
# ( requires 'ed' line editor )
# $ grep -Rn foo . | sed 's/foo/bar/' | wgrep
# ( 'wgrep -a' avoids trimming trailing spaces by default )
# Author: Gerald Lai
# License: 0BSD
@geraldlai
geraldlai / stun
Created November 10, 2017 07:01
stun: yet another ssh tunneling tool
#!/usr/bin/perl
# stun: ssh tunneling wrapper for convenient static port forwarding
# Author: Gerald Lai
# License: 0BSD
use warnings;
use strict;
@geraldlai
geraldlai / tmx
Created November 10, 2017 06:47
tmx: send keystrokes to tmux panes and new/split windows
#!/usr/bin/perl
# tmx: tmux execute (requires tmux v2.4+)
# Author: Gerald Lai
# License: 0BSD
use warnings;
use strict;
@geraldlai
geraldlai / git-mergic
Last active October 17, 2021 04:58
git-mergic: easy merge
#!/usr/bin/env perl
# git (mer)ge ma(gic) - DWIM rebasing
# $ git mergic master
# # Merging from: [origin] master
# ( merges or rebases current branch onto origin/master )
# Author: Gerald Lai
# License: 0BSD
@geraldlai
geraldlai / git-macho
Last active May 13, 2022 23:01
git-macho: git checkout drop-in replacement
#!/usr/bin/perl
# git (ma)gic (ch)eck(o)ut - Oooh keep it together, git!
#
# Each branch maintains its stashed changes separately & contained.
# Usage: 'git macho' drop-in replacement for 'git checkout'
# Author: Gerald Lai
# License: 0BSD
@geraldlai
geraldlai / keybase.md
Created October 21, 2017 07:06
Keybase Proof

Keybase proof

I hereby claim:

  • I am geraldlai on github.
  • I am geraldlai (https://keybase.io/geraldlai) on keybase.
  • I have a public key ASBTqM_G4735KEFfwf2caEvW7ZFQM9nGr-dCVo6SCdJFuQo

To claim this, I am signing this object: