Skip to content

Instantly share code, notes, and snippets.

Filewatcher

fswatch is a good program to react to file changes, e.g. run tests when files are updated. It's cross-platform.

fswatch path/to/file | xargs -n 1 bash_command
fswatch ./README.md | xargs -I {} -n 1 pandoc -o README.html README.md
fswatch -o ./*.js | xargs -I {} -n 1 npm test

Navigating and making it comfy on mac

Window management

The usual layout I need is a main window on the left and a secondary on the right, where the main window stays the same and the secondary changes applications. It should also be easy to fullscreen the current window.

Amethyst

@slarwise
slarwise / yamldiff.sh
Last active July 16, 2023 13:38
Compare two directories containing yaml files, e.g. two kubernetes environments for an app
#!/bin/bash
# Compare two directories containing yaml files recursively
# Dependencies:
# 1. [delta](https://github.com/dandavison/delta)
# Inputs:
# $1: First directory
# $2: Second directory
@slarwise
slarwise / init.vim
Last active July 16, 2021 20:17
Vim quickfix options, mappings and commands
" Open the quickfix window in a horizontal split at the bottom
" The height is the number of quickfix items (if it fits)
command! Copen execute "cclose | botright copen " . len(getqflist())
" Open the quickfix window in a vertical split to the left
command! Vcopen execute "cclose | copen | wincmd H"
" Add the cfilter plugin to enable the :Cfilter command
" This command lets you filter the quickfix list
packadd cfilter
@slarwise
slarwise / erlang.vim
Last active October 24, 2020 21:04
Setup for include-search for erlang in vim
" after/ftplugin/erlang.vim
setlocal suffixesadd=.erl,.hrl
let &l:define = '^-define(\|^-record(\|^-type \|^-type('
let &l:include = '^\s*-include("\zs\f*\ze").$'
setlocal path+=path/to/your/code/**
@slarwise
slarwise / init.vim
Last active June 12, 2023 10:01
Navigate vim splits in kitty terminal and other windows with the same skhd keybinds. Window manager yabai.
" The (neo)vim function that takes care of navigation within vim.
" Same concept as vim-tmux-navigator. If we navigate in the wanted
" direction and the winnr() hasn't changed, then we are at the edge
" and should forward the navigation to the window manager.
function! NvimYabaiNavigate(yabai_direction, vim_direction)
let win_nr_before = winnr()
execute("wincmd " . a:vim_direction)
if win_nr_before ==# winnr()
call system("yabai -m window --focus " . a:yabai_direction)