Skip to main content

Michael Uloth

TIL - Today I Learned

  1. Homebrew packages may install dependencies

    I wondered why brew list showed so many packages I didn’t install myself.

    Then, I discovered those are the dependencies of the packages I installed. And the dependencies of those dependencies. And so on.

    Seems kinda obvious now.

    # Which packages and casks are installed?
    brew list
    # Why is <package-name> installed? Which packages are using it?
    brew uses <package-name> --installed
    # Which dependencies came with <package-name>?
    brew deps <package-name> --tree
  2. Shell functions don't need parentheses

    Copilot surprised me by generating a zsh function that looked like this:

    function act {
      # do stuff
    }

    Instead of like this:

    act() {
      # do stuff
    }

    It turns out function parentheses are optional in bash and zsh. Though, using parentheses is more POSIX compliant if that’s relevant for your use case.

    In fact, all of these variations are equivalent:

    function act () { 
      command
    }
     
    function act() { 
      command 
    }
     
    function act { 
      command 
    }
     
    act () { 
      command 
    }
     
    act() { 
      command 
    }
     
    act () command
     
    act() command
  3. You can run shell scripts in tmux.conf
    1. Create a shell script:
    battery.sh
    #!/usr/bin/env bash
     
    echo "" $(pmset -g batt | grep -Eo '[0-9]+%')
    1. Make the file executable:
    chmod +x battery.sh
    1. Call it from within tmux.conf:
    tmux.conf
    set -g status-right "#($HOME/.config/tmux/battery.sh)"