A collection of scripts, files, etc. that I've written myself or collected from stack overflow over the years.
I use them in my dev environment (at my full time job) to make my life easier.
My ~/.zshrc file
My Brewfile
contains all my Homebrew formulae
To install my formulae
brew bundle
To generate your own Brewfile
to save your homebrew configuration
brew bundle dump
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.
Setup steps (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>
Script to enable autocomplete in zsh
Script to setup gcloud sdk via Homebrew
Script to update Homebrew, upgrade your formulae, and then run brew doctor
and brew cleanup
I have this aliased in my ~/.zshrc
and configured to run automatically when I open a new terminal window.
I have this in my ~/.zshrc
.
It works by using the builtin cd
command, running my functions after, and aliasing cd
. Check out the script for more details and to see everything that it does.