Skip to content

Instantly share code, notes, and snippets.

@LuizStSantos
Last active February 15, 2025 12:46
Show Gist options
  • Select an option

  • Save LuizStSantos/025c1c3775ff1f61e9f1001ef39b18b6 to your computer and use it in GitHub Desktop.

Select an option

Save LuizStSantos/025c1c3775ff1f61e9f1001ef39b18b6 to your computer and use it in GitHub Desktop.
Git branch on CLI ZSH

Git branch on CLI ZSH

What is it for? Used to view which branch you are in via the terminal without having to run 'git status'

Captura de Tela 2024-09-28 às 18 44 21

  • Open the .zshrc file:
nano ~/.zshrc
  • Add or modify the code at the end of the file:
# Alias
alias gs='git status'
alias cls='clear'

# Git
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )

# Configuring vcs_info for Git
zstyle ':vcs_info:git:*' formats 'on %F{011}⎇ %b%f'
zstyle ':vcs_info:*' enable git

setopt PROMPT_SUBST
PROMPT='%F{040}%n%f at %F{166}%m%f in %F{031}${PWD/#$HOME/~}%f ${vcs_info_msg_0_}'
  • Save and close the file: Press CTRL+O to save and CTRL+X to close nano.

  • Reload the .zshrc file:

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