Skip to content

Instantly share code, notes, and snippets.

View tweekmonster's full-sized avatar

Tommy Allen tweekmonster

View GitHub Profile
@tweekmonster
tweekmonster / python-imports.vim
Created April 27, 2016 06:09
Vim script to quickly edit the top portion of Python scripts using NrrwRgn
" A little annoying becuase NrrwRgn doesn't seem to be well suited for this.
" But, it gets the job done.
" Uses <leader>i in normal mode to open the split.
function! s:nrrw_head() abort
let saved = winsaveview()
keepjumps normal! 1G
let start = 1
let end = search('^\%(def\|class\)\s', 'ncW')
if !end
@tweekmonster
tweekmonster / edit-command-line.zsh
Created April 22, 2016 05:40
zsh edit-command-line zle widget that sets the cursor position in Vim
function edit-command-line() {
tmpfile=$(mktemp -t zsheditXXXXXXXX.sh)
print -R - "$PREBUFFER$BUFFER" > $tmpfile
editor=${VISUAL:-${EDITOR:-vi}}
args=()
if [[ "$editor" =~ vim ]]; then
pb=${#PREBUFFER}
(( b=pb+CURSOR ))
args+=("-c" ":call cursor(byte2line($b), ($b - $pb) + 1)")
fi
@tweekmonster
tweekmonster / agtrunc
Created May 18, 2015 17:53
A script to truncate the_silver_searcher's output in Vim
#!/usr/bin/env python
'''Truncates matches from ag
Place this script somewhere in your $PATH, like ~/bin and pipe ag into it.
Vim could be setup like this:
if executable('ag')
set grepprg=ag\ --vimgrep\ -w\ $*
if executable('agtrunc')
@tweekmonster
tweekmonster / AutoIndent_Demo.scpt
Created February 24, 2016 18:04
Script for creating the autoindent GIF for braceless.vim
-- Script for creating the autoindent GIF for braceless.vim
-- https://github.com/tweekmonster/braceless.vim
to slowType(someText)
tell application "System Events"
repeat with i from 1 to count characters of someText
keystroke (character i of someText)
delay 0.15
end repeat
end tell
@tweekmonster
tweekmonster / client.sh
Created September 26, 2015 01:42
Monitor FIFO pipe with Bash
#!/bin/bash
echo -en "${@}\x04" > /tmp/fifo_queue