Last active
September 9, 2022 15:48
-
-
Save kfox/6a315e84aff8ef5763f630e43b517c48 to your computer and use it in GitHub Desktop.
Define and set dynamic variables for iTerm2 badges and status bar components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iterm2_print_user_vars() { | |
# git repository and branch, if available | |
iterm2_set_user_var gitRepo "$(git config --get remote.origin.url | xargs basename -s .git)" | |
iterm2_set_user_var gitBranch "$(git rev-parse --abbrev-ref HEAD 2>/dev/null | xargs)" | |
# node, ruby, and python versions | |
# shellcheck disable=SC2086 | |
iterm2_set_user_var nodeVersion "$(v=$(node -v 2>/dev/null); echo -n ${v/v/} || echo -n 'N/A')" | |
iterm2_set_user_var rubyVersion "$(ruby -v 2>/dev/null | cut -d' ' -f2)" | |
# shellcheck disable=SC2086 | |
iterm2_set_user_var pythonVersion "$(v=$(python --version 2>&1); echo -n ${v/Python /})" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment