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 /
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 Dec 2, 2019
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')
View brightness.rb
#!/usr/bin/env ruby
# Brett Terpstra 2019
# This script adds the ability to increment/decrement display brightness
# levels to the nriley/brightness CLI (Copyright (c) 2014-2019, Nicholas Riley)
# Requires CLI installation: `brew install brightness`
# See
CMD = "/usr/local/bin/brightness"
# Display usage and exit
def usage(code)

A CLI for by Brett Terpstra

Save the file below as bunch in your path. Run bunch -h for help.

CLI for
    -h, --help                       Display this screen
    -f, --force-refresh              Force refresh cached preferences
    -l, --list                       List available Bunches
    -o, --open                       Open Bunch ignoring "Toggle Bunches" preference
ttscoff / Example.bunch
Last active Jun 11, 2019
Sample .bunch file for
View Example.bunch
# Comments start with a hash symbol, blank lines are ignored
# Use @@ to hide all visible apps. Usually used at the top of the file
# before launching the rest of the bunch
# Apps to launch start at the beginning of a line, no
# need to quote or escape.
ttscoff / onsetapp.rb
Last active Aug 19, 2019
Check which Setapp Apps you could be using
View onsetapp.rb
#!/usr/bin/env ruby
# encoding: utf-8
# Read /Applications/Setapp to get apps already installed
installed_setapp_apps = Dir.glob('/Applications/Setapp/*.app')! {|app|
# Grab the All Apps page from Setapp to get all available apps
You can’t perform that action at this time.