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
ttscoff / commandline.fish
Last active Nov 11, 2019
Fish functions with commandline tricks
View commandline.fish
# Defined in /Users/ttscoff/.config/fish/functions/__prev_token.fish @ 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
end
# Defined in /Users/ttscoff/.config/fish/functions/__re_extension.fish @ line 1
function __re_extension --description 'remove extension from word under/before cursor'
commandline -f forward-word
@ttscoff
ttscoff / bid.fish
Created Nov 9, 2019
bid command for Fish
View bid.fish
# Defined in /Users/ttscoff/.config/fish/brett.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/$shortname.app"
set location "/Applications/$shortname.localized/$shortname.app"
else if test -d "/Applications/$shortname.app"
set location "/Applications/$shortname.app"
@ttscoff
ttscoff / fish_prompt.fish
Last active Nov 10, 2019
Brett's fish prompt, based on Bira
View fish_prompt.fish
# biras_weird_cousin
# Theme based on Bira theme from oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/bira.zsh-theme
# Some code stolen from oh-my-fish clearance theme: https://github.com/bpinto/oh-my-fish/blob/master/themes/clearance/
# Adds a badge if we're in an SSH session (first letter of hostname, uppercased)
function __ssh_badge
if test -n "$SSH_CLIENT$SSH2_CLIENT$SSH_TTY"
set_color -b d6aeec -o 2a0a8b
echo -n " "(string upper (string sub -s 1 -l 1 (hostname -s)))" "
set_color normal
@ttscoff
ttscoff / brett.fish
Last active Nov 11, 2019
Brett's Fish Shell custom init file
View brett.fish
function __should_na
set -l cmd (history --max=1|awk '{print $1;}')
set -l cds cd z j popd g
if contains $cmd $cds
~/scripts/fish/na
end
end
function fallback --description 'allow a fallback value for variable'
if test (count $argv) = 1
@ttscoff
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
end
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 https://github.com/nriley/brightness
CMD = "/usr/local/bin/brightness"
# Display usage and exit
def usage(code)
View README.md

A CLI for Bunch.app by Brett Terpstra

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

CLI for Bunch.app
    -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
ttscoff / Example.bunch
Last active Jun 11, 2019
Sample .bunch file for Bunch.app
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.
Messages
@ttscoff
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')
installed_setapp_apps.map! {|app|
File.basename(app,'.app')
}
# Grab the All Apps page from Setapp to get all available apps
@ttscoff
ttscoff / macsymbols.rb
Created Apr 19, 2019
Convert liquid-style tags for Mac symbols into HTML entities
View macsymbols.rb
class String
def replace_with_entity
case self.downcase
when /apple/
""
when /(comm(and)?|cmd|clover)/
"⌘"
when /(cont(rol)?|ctl|ctrl)/
"⌃"
when /(opt(ion)?|alt)/
You can’t perform that action at this time.