Skip to content

Instantly share code, notes, and snippets.

@TravisCarden
Last active January 8, 2024 03:16
Show Gist options
  • Save TravisCarden/7cc86237b43d6921f0872058e908fb92 to your computer and use it in GitHub Desktop.
Save TravisCarden/7cc86237b43d6921f0872058e908fb92 to your computer and use it in GitHub Desktop.
iTerm2 status bar component for the latest Git commit message

iTerm2 status bar component for the latest Git commit message

screenshot

Generate the component text

# bash: Place this in .bashrc.
# zsh: Place this in .zshrc.
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
function iterm2_print_user_vars() {
  iterm2_set_user_var gitLastCommitMessage "$(if [ -d .git ]; then; git show --format=%s -s 2>/dev/null; fi)"
}

Create the component

In iTerm2...

  • Right-click on the status bar and click "Configure Status Bar".
  • Click and drag the "Interpolated String" component onto the "Active Components"
  • Click to select it and click the "Configure Component" button at the bottom left of he dialog box.
  • Set the string value to 𐌒 \(user.gitLastCommitMessage), optionally configure the display details, and click "OK".

That's it. 🙂

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment