Skip to content

Instantly share code, notes, and snippets.

@singularitti
Last active April 22, 2024 04:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save singularitti/9c2307690441bb30108ab3902aa2834a to your computer and use it in GitHub Desktop.
Save singularitti/9c2307690441bb30108ab3902aa2834a to your computer and use it in GitHub Desktop.
Homebrew snippets
using IOCapture
export livecheck, bump_cask_pr
function livecheck(cask)
try
c = IOCapture.capture() do
run(`brew livecheck --cask $cask`)
end
str = c.output
regex = Regex(cask * ":[ ]+([^=]+)[ ]+==>[ ]+([^\n]+)")
m = match(regex, str)
if !isnothing(m)
old, new = m.captures
if new >= old
return new
end
end
catch e
print(e)
return nothing
end
end
function bump_cask_pr(cask)
version = livecheck(cask)
if !isnothing(version)
try
run(`brew bump-cask-pr $cask --no-browse --write-only --commit --version $version`)
catch e
print(e)
return nothing
end
end
end
#!/bin/bash
brew alias au='audit --new --online'
brew alias arm='autoremove'
brew alias b='bundle'
brew alias bd='bundle dump'
brew alias ug='upgrade'
brew alias dt='deps --tree'
brew alias i='install'
brew alias if='info'
brew alias e='edit'
brew alias h='home'
brew alias ri='reinstall'
brew alias l='list --formula'
brew alias le='leaves'
brew alias o='outdated'
brew alias s='search'
brew alias sf='style --fix'
brew alias c='cleanup --prune=all -s'
brew alias use='uses --recursive --installed' # From https://zanshin.net/2014/02/03/how-to-list-brew-dependencies/
brew alias fpr='bump-formula-pr --no-browse --version'
brew alias z='uninstall --force --zap'
# From https://zanshin.net/2014/02/03/how-to-list-brew-dependencies/
brew list --formula | while read cask; do
echo -n "\e[1;34m$cask ->\e[0m"
brew deps $cask | awk '{printf(" %s ", $0)}'
echo ""
done
brew alias ci='install --cask'
brew alias cl='list --cask'
brew alias cx='uninstall --cask'
brew alias cz='uninstall --zap --force --cask'
brew alias cif='info --cask'
brew alias cpr='!julia -e "include(expanduser(\"~/.brew.jl\")); bump_cask_pr(ARGS[1])"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment