A collection of scripts, config, etc. that I've written myself or collected from stack overflow (or coworkers) over the years.
My ~/.zshrc file
Brewfile
contains all my Homebrew formulae
To generate your own Brewfile
to save your homebrew configuration
brew bundle dump
To install my formulae
brew bundle
Works by aliasing the builtin cd
command to my git_cd
function, which runs a bunch of git
commands under the hood.
The function handles fetching, pulling, and then gracefully returning you to your originally checked out branch and state.
Check out the full script here.
It lives directly in my .zshrc
file.
Includes functions I run automatically when I start a new terminal
The steps below walk through how to make custom functions available outside of aliasing them and how to run them automatically when you start a new terminal session.
Mostly copied from a Stack Exchange post)
-
My
~/.mel-zsh-functions
directory contains my custom functions, with a file for each function.
To get this working for yourself:- Your directory can be called anything and can be located anywhere on your computer
- The function script file must be named the name of the function, with no file extension
- The file itself can contain any
bash/zsh
scripting and doesn't need to be wrapped infunction <function_name> {}
or contain#!/bin/bash
zsh
is designed so that the name of the file is the function name
-
Add or update the
FPATH
environment variable to include the directory with your functions.
For example, I added the line below to my~/.zshrc
export FPATH=~/.mel-zsh-functions:$FPATH
⚠️ Do not put any quotes around theFPATH
value. It will not work.At this point, you can call your function(s), assuming you've opened a new terminal window or sourced your
~/.zshrc
. For example, if I want to run the functionhomebrew_sync
, I just typehomebrew_sync
in my terminal window, hit enter, and it runs. -
For any functions you'd like to run automatically whenever a new terminal window is opened, you need to add a line to your
~/.zshrc
autoload -U +X <your_function> && <your_function>
Prequisites
-
python
installed -
Run these commands
brew install bash-completion pip install argcomplete activate-global-python-argcomplete
Partially taken from stack overflow.
Prequisites
Update Homebrew, upgrade your formulae, and then run brew doctor
and brew cleanup
.
Sets HOMEBREW_GITHUB_API_TOKEN
to prevent homebrew use limits.