Skip to content

Instantly share code, notes, and snippets.

Brett Terpstra ttscoff

Block or report user

Report or block ttscoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ttscoff / convert_to_quiver.rb
Created Apr 30, 2020
Markdown files to Quiver JSON
View convert_to_quiver.rb
#!/usr/bin/env ruby
require 'json'
require 'fileutils'
notebook = File.expand_path('~/Desktop/NewSnippets.qvnotebook')
nbmeta = {
"name" => "NewSnippets",
"uuid" => %x{uuidgen}.strip
ttscoff / mmdtagstomacos.rb
Last active Apr 18, 2020
Read MultiMarkdown metadata tags from files and apply them as macOS tags
View mmdtagstomacos.rb
#!/usr/bin/env ruby
# encoding: utf-8
# Read MultiMarkdown metadata tags from files and apply them as macOS tags
# Usage:
# mmdtagstomacos.rb *.md
require 'shellwords'
mmd = '/usr/local/bin/multimarkdown'
ttscoff /
Created Feb 18, 2020
Dad jokes for Fish shell
# You're welcome
function dadjoke -d 'Get a dad joke from'
curl -H "Accept: text/plain"
ttscoff / tunes.rb
Created Feb 15, 2020
CLI controls for Spotify and (Apple) Music
View tunes.rb
#!/usr/bin/env ruby
# encoding: utf-8
# CLI music controller for Spotify and Apple Music
# By default affects whichever one is running, preferring Spotify
# if both are. Change the order of KNOWN_PLAYERS to reverse that.
# If the first argument is either "music" or "spotify," it will
# target that app. If the app is not running, it will be launched.
# When no app is specified and neither are running, it returns nothing
ttscoff /
Created Dec 17, 2019
Fish completion for tm.bash
# ~/.config/fish/completions/
function __tm_has_no_args
set -l cmd (commandline -opc)
echo $cmd
return (test (count $cmd) -eq 1)
function __tm_has_windows
set -l cmd (commandline -opc)
set -l res (tmux list-windows -t $cmd[-1] 2>/dev/null >/dev/null)
ttscoff /
Last active Nov 11, 2019
Fish functions with commandline tricks
# Defined in /Users/ttscoff/.config/fish/functions/ @ line 1
function __prev_token -d "repeats last token on the command line"
set -l buffer (commandline -bo)
commandline -a " "$buffer[-1]
commandline -f end-of-line
# Defined in /Users/ttscoff/.config/fish/functions/ @ line 1
function __re_extension --description 'remove extension from word under/before cursor'
commandline -f forward-word
ttscoff /
Created Nov 9, 2019
bid command for Fish
# Defined in /Users/ttscoff/.config/fish/ @ line 240
function bid --description 'Get bundle id for app name'
set -l shortname (echo "$argv"| sed -E 's/\.app$//'|sed 's/\\\//g')
set -l location
# if the file is a match in apps folder, don't spotlight
if test -d "/Applications/$shortname.localized/$"
set location "/Applications/$shortname.localized/$"
else if test -d "/Applications/$"
set location "/Applications/$"
ttscoff /
Last active Nov 27, 2019
Brett's fish prompt, based on Bira
# biras_weird_cousin
# Theme based on Bira theme from oh-my-zsh:
# Some code stolen from oh-my-fish clearance theme:
# Adds a badge if we're in an SSH session (first letter of hostname, uppercased)
function __ssh_badge
set_color -b d6aeec -o 2a0a8b
echo -n " "(string upper (string sub -s 1 -l 1 (hostname -s)))" "
set_color normal
ttscoff /
Last active Feb 8, 2020
Brett's Fish Shell custom init file
function __should_na
set -l cmd (history --max=1|awk '{print $1;}')
set -l cds cd z j popd g
if contains $cmd $cds
function fallback --description 'allow a fallback value for variable'
if test (count $argv) = 1
ttscoff / linkmarks.rb
Last active Oct 11, 2019
A script to convert Bashmarks .sdirs file to Fish's Jump plugin symlinks
View linkmarks.rb
#!/usr/bin/env ruby
# A script to convert Bashmarks .sdirs file to Fish's Jump plugin symlinks
sdirs_file = File.expand_path('~/.sdirs')
unless File.exists?(sdirs_file)
$stderr.puts 'Bookmarks file not found (~/.sdirs). Is Bashmarks initialized?'
Process.exit 1
marks = File.expand_path('~/.marks')
You can’t perform that action at this time.