Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compound Commands installs commands in /usr/local/bin/. that combine a few commands to give a desired result. Geared towards ease of use
# Development has moved to:
# https://github.com/dchakro/brewlog

The gists here contain bash scripts that install commands in /usr/local/bin, you may need sudo depending on your permissions.

The installed command usually chains together a series of commands to achieve desired results and requires only a few keysctrokes to invoke instead of typing a long string of parameters and pipes everytime.

Includes:

  1. brewlog brewlog = run homebrew's brew commands while saving the stdoutto a log file in your ~/Logs/brew.log
    • Not to be confused with brew log which shows the commit history (similar to git log).
    • I need to find a new name, but for now as I personally don’t use brew log, I had no “merge conflicts” in my brain while assigning brewlog to achive my desired result of logging brew output :) [IMHO brew history might have been a better name for brew log]
  2. lrg = output of ripgrep piped to less

How to installing these compound commands:

# Install brewlog
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/install.sh' | bash

# Install lrg
curl -sSL "https://gist.githubusercontent.com/dchakro/3e9792b6e47c3648e725fb518a2dbf68/raw/lrg.sh" | bash

What not setup simple aliases ?

These commands defined here are fundamentally different than aliases as:

  1. They often combine some operations

  2. They take in the '$@' parameter and which is used to pass along all the arguments that are used in the SHELL to the main command being invoked.

# This script installs the command usr/local/bin/lrg
# lrg is uses optimal parameters for less and ripgrep and pipes output o ripgrep to less
# checkout ripgrep: https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md
# How to use:
# lrg -N "mutation" *.R
# lrg "alias l" .zim/*
cat > /usr/local/bin/lrg <<'EOL'
#!/usr/bin/env sh
$(which rg) -p "$@" | less -RFX
EOL
chmod +x /usr/local/bin/lrg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment