Skip to content

Instantly share code, notes, and snippets.

@mikeslattery
mikeslattery / .idea-lazy.vim
Last active March 11, 2025 12:01
LazyVim mappings for Jetbrains IDEs
" ~/.idea-lazy.vim
" LazyVim mappings for Jetbrains IDEs
" Required plugins. https://plugins.jetbrains.com/bundles/7-ideavim-bundle
" IDEAVim
" Which-Key
" IdeaVim-Sneak
" To install, add this to the top of your ~/.ideavimrc:
@mikeslattery
mikeslattery / focusterm.sh
Created February 23, 2025 23:13
Set focus of app running in a terminal.
#!/bin/bash
# Focus the window for the current terminal.
# Usage: focusterm
# Supports:
# X11
# tmux
# kitty, westerm, alacrity, and most other terminals
@mikeslattery
mikeslattery / nvims.sh
Created January 9, 2025 21:19
Neovim configuration selector
#!/bin/bash
set -euo pipefail
# Neovim configuration selection
# Provides a fuzzy search for all directories under ~/.config for init.lua
# Usage: nvims
# Requires:
# fzf
@mikeslattery
mikeslattery / ssh2config.sh
Last active May 20, 2024 13:13
Convert shell history or CLI args into ~/.ssh/config format.
#!/bin/bash
ssh2append() {
ssh -G "$@" | sed -n 's/^hostname /Host /p'
comm -23 <(ssh -G "$@" 2>/dev/null | sort) <(ssh -G . 2>/dev/null | sort) | sed 's/^/ /'
# This loop+if is for remote command, -N, -W as -G lacks support
while getopts '1246AaCfGgKkMNnqsTtVvXxYyB:b:c:D:E:e:F:I:i:J:L:l:m:O:o:p:Q:R:S:W:w:' opt; do
#shellcheck disable=SC2254
case "$opt" in
@mikeslattery
mikeslattery / briefmarks.lua
Last active March 18, 2024 14:18
which_key.nvim extension to limit how many marks are shown.
local M = {}
--
-- $HOME/.config/nvim/lua/which-key/plugins/briefmarks.lua
--
-- This extends which-key/plugins/marks.lua with these changes:
--
-- * Only show subset of marks
-- * Letters
-- * ^ . quote
@mikeslattery
mikeslattery / git-syncr
Last active February 25, 2024 20:23
Git Directory Synchronizer
#!/bin/bash
help() { cat<<HELP
git-syncr - git worktree synchronizer
Usage: git syncr <command>
COMMANDS:
create <path> [<branch>]
Create new worktree at <path> forked from current directory.
@mikeslattery
mikeslattery / gvim-ide-intg.md
Last active January 26, 2024 14:02
How to loosely integrate IdeaVim and gVim

This will allow you to switch between a Jetbrains IDE and gVim at the same file/line/column by hitting <leader>i. Hit <leader><leader>i to start gVim (once).

I've also done this with terminal Vim, but it's much more complex and varies depending on your environment (OS, DE, multiplexers, terminal).

Steps:

Install gVim and the IdeaVim plugin

In IDE: Settings > Build,Execution,Deployment > check "Allow unsigned requests"

@mikeslattery
mikeslattery / webcam2html.sh
Last active November 16, 2023 21:11
AI Webcam to html
#!/bin/bash
# Takes a photo and converts to a project text artifact.
# Just experimental for now.
set -euo pipefail
THISDIR="$(dirname "$0")"
#shellcheck disable=SC1091
source "$THISDIR/.env"
docker system df
df -h
# Delete builds and workspaces more 6+ months old
find /var/lib/jenkins/jobs -maxdepth 6 -mtime +180 -name build.xml -print0 | xargs -0 -I{} dirname {} | xargs -d '\n' -r rm -rf
find /var/lib/jenkins/jobs -maxdepth 3 -mtime +180 -name workspace -print0 | xargs -0 -r rm -rf
# Stop containers running more than 2 days, except Jenkins
docker ps | grep -E 'days|weeks|months' | grep -Ev "$(hostname)|CONTAINER" | awk '{ print $1; }' | xargs -r docker stop
@mikeslattery
mikeslattery / .vimrc
Last active February 23, 2023 20:19
Beginner's Minimal Vim Config
" This is a beginners .vimrc or init.vim file
" with sane defaults so you can be productive at the start.
" Not designed to work with Neovim.
" Sane defaults.
source $VIMRUNTIME/defaults.vim
set mouse=a " Enable mouse
set clipboard+=unnamed,unnamedplus " Use desktop's clipboard
set hidden " Allow switch buffers if current not saved
set noswapfile autoread " Swap file annoyance. Use git.