Skip to content

Instantly share code, notes, and snippets.

View gregsexton's full-sized avatar

Greg Sexton gregsexton

View GitHub Profile
@gregsexton
gregsexton / PersDirs.py
Created May 20, 2012 21:08
Persistent directory tracking
import sys
import os.path
import pickle
from SizeLimitedStack import *
PERSISTENT_FILE = os.path.expanduser('~/.persdirs')
def add_dir_to_stack(new_dir):
idx = sls.find(new_dir)
if idx > -1: sls.move_to_top(idx)
@gregsexton
gregsexton / objc.vim
Created May 31, 2012 20:41
The core of my objc.vim ftplugin
setlocal makeprg=xcodebuild\ -configuration\ Debug
setlocal errorformat=%f:%l:%c:%.%#\ error:\ %m,%f:%l:%c:%.%#\ warning:\ %m,%-G%.%#
command! -buffer OpenFileInXCode silent !xed %
command! -buffer RebuildTags exec "!~/bin/ctags -R --language-force=ObjectiveC ."
nmap <buffer> <silent> K :exec 'silent !open "'. escape('http://www.google.com/search?q='.expand('<cword>').'&btnI=745', ' &!%').'"'<cr>:redraw!<cr>
@gregsexton
gregsexton / gist:8195599
Last active July 1, 2016 04:45
My rsync-based backup script
#! /bin/zsh
# Backup script written by Greg Sexton
# bomb out on first non-zero exit code
set -e
trap 'echo !!! BACKUP EXITED WITH ERROR STATUS !!!' ERR
DATE=$(date "+%Y-%m-%dT%H:%M:%S")
ROOT=/mnt/backup
BACKUP_PREFIX="bak-"
#!/usr/bin/env bash
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "Not in a git repository."
exit 1
fi
head_log_line=$(git log --pretty='%d %s' HEAD -1)
if current_branch=$(git symbolic-ref -q HEAD); then
@gregsexton
gregsexton / gist:dd2d6c304d06fc3e6833
Created July 11, 2015 17:50
Company backend for completing eshell history
(defun company-eshell-history (command &optional arg &rest ignored)
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-eshell-history))
(prefix (and (eq major-mode 'eshell-mode)
(let ((word (company-grab-word)))
(save-excursion
(eshell-bol)
(and (looking-at-p (s-concat word "$")) word)))))
(candidates (remove-duplicates