Skip to content

Instantly share code, notes, and snippets.

View rkitover's full-sized avatar

Rafael Kitover rkitover

  • San Francisco, CA, United States
View GitHub Profile
@rkitover
rkitover / zsh-history-completion.sh
Last active September 9, 2024 13:29
zsh-autosuggestions config
source ~/source/repos/zsh-autosuggestions/zsh-autosuggestions.zsh
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search # Up
bindkey "^[[B" down-line-or-beginning-search # Down
@rkitover
rkitover / ports.sh
Created September 7, 2024 05:42
List open ports shell function
ports() {
(
echo 'PROC PID USER x IPV x x PROTO BIND PORT'
(
sudo lsof +c 15 -iTCP -sTCP:LISTEN -P -n | tail -n +2
sudo lsof +c 15 -iUDP -P -n | tail -n +2 | egrep -v ' (127\.0\.0\.1|\[::1\]):'
) | sed -E 's/ ([^ ]+):/ \1 /' | sort -k8,8 -k5,5 -k1,1 -k10,10n
) | awk '{ printf "%-16s %-6s %-9s %-5s %-7s %s:%s\n",$1,$2,$3,$5,$8,$9,$10 }'
}
@powershell -c ". $profile; %2% %3% %4% %5% %6% %7% %8% %9%"
@rkitover
rkitover / irclog.sh
Created August 7, 2024 03:36
page weechat irc logs
irclog() {
chan_log=$(find ~/.weechat/logs -name "*.#${1}.*" -printf '%p ' | sed 's/ $//')
case "$chan_log" in
*" "*)
echo >&2 'irclog: multiple matches'
unset chan_log
return 1
;;
"")
@rkitover
rkitover / build-tmux-windows.sh
Last active August 21, 2024 00:40
build experimental tmux for Windows
#!/bin/bash
pacman -S --noconfirm --needed base-devel git make autotools autoconf-archive libtool pkgconf libevent-devel windows-default-manifest msys2-runtime-devel msys2-w32api-headers gcc bison
rm -rf ~/tmux-windows
mkdir ~/tmux-windows
pushd ~/tmux-windows
git clone https://github.com/rkitover/MSYS2-packages.git
pushd MSYS2-packages/ncurses
@rkitover
rkitover / sudo.ps1
Last active June 16, 2024 20:11
PowerShell sudo hack for Windows
# This requires localadmin and pwsh/winps as your ssh shell.
function global:sudo {
$cmd = [management.automation.invocationinfo].getproperty('ScriptPosition',
[reflection.bindingflags] 'instance, nonpublic').getvalue($myinvocation).text -replace '^\s*sudo\s*',''
ssh localhost -- "sl '$(get-location)'; $cmd"
}
@rkitover
rkitover / ble-setup.md
Last active June 3, 2024 08:31
Setup ble.sh for PowerShell-like history completion in bash

Setup ble.sh for PowerShell-like history completion in bash

These settings will give you PowerShell-like history completion in bash using ble.sh.

History completions will be displayed in grey, press UP-ARROW or F8 to accept the completion and ENTER.

To cancel a completion, press CTRL-K or DOWN-ARROW.

@rkitover
rkitover / boot-linux.ps1
Last active October 22, 2023 02:15
trivial script to delete GRUB env to boot Linux
# Script to remove the GRUB environment file, resetting the default GRUB entry
# to what is usually the user's latest Linux kernel.
$grubenv = 'z:/grub/grubenv'
# Relaunch as an elevated process.
if (-not ([security.principal.windowsprincipal] [security.principal.windowsidentity]::getcurrent() `
).isinrole([security.principal.windowsbuiltInrole]::administrator) `
) {
$pwsh = [system.diagnostics.process]::getcurrentprocess().mainmodule.filename
--- glib-original/meson.build 2023-05-31 01:05:34
+++ glib/meson.build 2023-05-31 04:32:57
@@ -2103,6 +2103,8 @@
libintl_deps = []
libintl_prefix = '#include <libintl.h>'
libintl = dependency('intl', required: false, allow_fallback: false)
+libiconv = dependency('iconv', required: false)
+mac_cf = dependency('appleframeworks', modules: ['CoreFoundation'], required: false)
if libintl.found()
# libintl supports different threading APIs, which may not
## arrow up
"\e[A":history-search-backward
## arrow down
"\e[B":history-search-forward