Skip to content

Instantly share code, notes, and snippets.

@ttscoff
ttscoff / geticonpng.bash
Created Sep 12, 2020
Grab a PNG of any local Mac app icon
View geticonpng.bash
#!/bin/bash
# get any app's full-size icon, PNG version
function geticonpng() {
# Autocompletes app names with modified .app_completions scripts
APP=`echo $1|sed -e 's/\.app$//'`
APPDIR=''
for dir in "/Applications/" "/Applications/Setapp/" "/Applications/Utilities/" "/Users/ttscoff/Applications/" "/Developer/Applications/" "/Developer/Applications/Utilties/" "/System/Applications/"; do
if [[ -d "${dir}$APP.app" ]]; then
APPDIR="$dir"
@ttscoff
ttscoff / Podcast.bunch
Last active Sep 15, 2020
Brett's Bunch.app bunch for podcasting
View Podcast.bunch
# Start podcasting
## Some time tracking
& workflows/Timing
- task = Podcasting
- project = Podcasting
## Do not disturb me, audio settings
(dnd on)
@ttscoff
ttscoff / volumetoggle.rb
Created Sep 11, 2020
Script for macOS to save and restore audio input/output device and volume settings
View volumetoggle.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
# Brett Terpstra <https://brettterpstra.com>
#
# macOS: Stores all input/output devices and volume settings to a
# text file, restores on demand
#
## Dependencies
# SwitchAudioSource <https://github.com/deweller/switchaudio-osx>
@ttscoff
ttscoff / Dropbox and Backblaze.bunch
Created Aug 7, 2020
Bunch.app pause/resume tricks for Dropbox and Backblaze (ideal for Podcast-related Bunches)
View Dropbox and Backblaze.bunch
# Tricks for Bunch.app
# <https://brettterpstra.com/projects/bunch/>
# Normally we would quit Dropbox just by using:
# !Dropbox
# But Dropbox has some issues with an AppleScript-style quit
# so we revert to sending a KILL signal via shell script
$ killall Dropbox
# if you want to open the Dropbox process when toggling
@ttscoff
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')
FileUtils.mkdir_p(notebook)
nbmeta = {
"name" => "NewSnippets",
"uuid" => %x{uuidgen}.strip
@ttscoff
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
ttscoff / dadjoke.fish
Created Feb 18, 2020
Dad jokes for Fish shell
View dadjoke.fish
# You're welcome
function dadjoke -d 'Get a dad joke from icanhazdadjoke.com'
curl -H "Accept: text/plain" https://icanhazdadjoke.com/
end
@ttscoff
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
ttscoff / tm.fish
Created Dec 17, 2019
Fish completion for tm.bash
View tm.fish
# ~/.config/fish/completions/tm.fish
function __tm_has_no_args
set -l cmd (commandline -opc)
echo $cmd
return (test (count $cmd) -eq 1)
end
function __tm_has_windows
set -l cmd (commandline -opc)
set -l res (tmux list-windows -t $cmd[-1] 2>/dev/null >/dev/null)
@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
You can’t perform that action at this time.