Skip to content

Instantly share code, notes, and snippets.

View ttscoff's full-sized avatar
💭
Breathing

Brett Terpstra ttscoff

💭
Breathing
View GitHub Profile
@ttscoff
ttscoff / Instant Search.applescript
Last active February 20, 2025 09:46
A LaunchBar action to use SearchLink as a quick access tool for the web.
(* Instant Search for LaunchBar by Brett Terpstra
Requires SearchLink installed in ~/Library/Services (http://brettterpstra.com/projects/searchlink/)
Load the service in LaunchBar and type Space. Enter text, optionally starting with a SearchLink !arg
to define the desired search engine. (You do not need the "!!" at the end to specify only url).
The link will be returned, pressing Enter will open it. ⌘C will copy.
*)
on handle_string(message)
set _chars to reverse of characters of message
@fcrespo82
fcrespo82 / .bash_completion
Last active August 29, 2015 13:57
A shell completion for Brett Terpstra's doing command line utility http://brettterpstra.com/projects/doing/
_doing()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(doing help -c)" -- $cur) )
}
complete -F _doing doing
@ttscoff
ttscoff / total_numbers.rb
Created April 7, 2014 19:42
Sum all numbers found in the input
#!/usr/bin/ruby
decimal = "."
separator = ","
if RUBY_VERSION.to_f > 1.9
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
input = STDIN.read.force_encoding('utf-8')
else
@ttscoff
ttscoff / spl.rb
Created May 2, 2014 14:46
A Sentaku-based wrapper for mdfind
#!/usr/bin/ruby
require 'shellwords'
query = ARGV.length > 0 ? ARGV.join(" ") : "date:today"
files = %x{mdfind '#{ARGV.join(" ")}'}.split("\n")[0..100]
filehash = {}
files.each {|file|
base = File.basename(file)
@ttscoff
ttscoff / folderize.rb
Created May 4, 2014 13:37
A script to create nested folders from a flat folder containing files with configured prefixes
#!/usr/bin/env ruby
require 'yaml'
require 'fileutils'
class Folderize
def initialize(config_file=false)
config_file = File.expand_path("~/.folderize") unless config_file
# Set up config
unless File.exists?(config_file)
@ttscoff
ttscoff / tm.bash
Last active September 10, 2024 19:55
A shell function to wrap tmux and make the basic commands a bit easier
#!/bin/bash
__lower() {
echo "$@"|tr "[:upper:]" "[:lower:]"
}
__menu() {
local result=""
PS3=$1
shift
@ttscoff
ttscoff / up.sh
Last active February 20, 2025 09:42
up: Quickly cd up a directory tree
# inspired by `bd`: https://github.com/vigneshwaranr/bd
function _up() {
local rx updir
rx=$(ruby -e "print '$1'.gsub(/\s+/,'').split('').join('.*?')")
updir=`echo $PWD | ruby -e "print STDIN.read.sub(/(.*\/${rx}[^\/]*\/).*/i,'\1')"`
echo -n "$updir"
}
function up() {
if [ $# -eq 0 ]; then
#!/bin/bash
# Bash completion for `up` <http://brettterpstra.com/2014/05/14/up-fuzzy-navigation-up-a-directory-tree/>
_up_complete()
{
local rx
local token=${COMP_WORDS[$COMP_CWORD]}
local IFS=$'\t'
local words=$(dirname `pwd` | tr / " ")
local nocasematchWasOff=0
@ttscoff
ttscoff / tm.completion.bash
Last active February 20, 2025 09:42
Fuzzy Bash completion for tmux session/window using [tm](http://brettterpstra.com/2014/05/11/making-my-tmux-life-easier/)
_tm_complete() {
local rx
local token=${COMP_WORDS[$COMP_CWORD]}
local IFS=$'\t'
local words
if [ $COMP_CWORD -eq 2 ]; then
words=$(tmux list-windows -t ${COMP_WORDS[1]} 2> /dev/null | awk '{print $2}' | tr -d '*-' | tr "\n" "\t")
elif [ $COMP_CWORD -eq 1 ]; then
words=$(tmux -q list-sessions 2> /dev/null | cut -f 1 -d ':' | tr "\n" " ")
fi
@ttscoff
ttscoff / mindmeister_store.rb
Last active December 19, 2022 22:43
Store Markdown exports (as well as PDF and other formats) of all MindMeister maps in an account. See https://brettterpstra.com/2014/05/27/mirror-your-mindmeister-maps-to-nvalt/ for usage
#!/usr/bin/env ruby
require 'digest/md5'
require 'uri'
require 'net/http'
require 'yaml'
require 'rexml/document'
require 'fileutils'
require 'time'
require 'open-uri'