Skip to content

Instantly share code, notes, and snippets.

@mikeslattery
mikeslattery / .idea-lazy.vim
Last active April 14, 2026 20:22
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 / clone_to_docker.sh
Last active March 24, 2026 20:43
Convert local Linux distro into a container.
#!/bin/bash
# Usage - clone_to_docker.sh <image-name>
# This will convert the local distro to a container image and run it.
# Also works for WSL.
# The container will run as the user that created the image.
# If using WSL, you should mount (or symlink) /c to /mnt/c
image="wsl"
@mikeslattery
mikeslattery / git-syncr
Last active March 6, 2026 15:59
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 / x-platform.sh
Last active February 9, 2026 06:38
Cross Platform Bash Snippet for Linux, WSL 1, Cygwin, Msys, and GitBash.
#!/bin/bash
# shebang added only to appease shellcheck
# Cross-platform for bash.
# Worry less about when writting a script that must run on Windows, Linux, and Mac.
# Meant to be used with "source" command in scripts.
# Compatiblity with MacOS's old bash
if [ -z "${ZSH_VERSION:-}" ] && [ "${BASH_VERSION%%.*}" -lt 5 ] && command -v zsh &>/dev/null; then
# MacOS: If running old Bash and Zsh is avilable, rerun with Zsh
@mikeslattery
mikeslattery / .vimrc
Last active November 21, 2025 03:55
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.
@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 / 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"