Last active
February 24, 2026 15:47
-
-
Save ColtHands/2a2a0ce08676667a8dd5252353bac810 to your computer and use it in GitHub Desktop.
My zshell config
This file contains hidden or 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
| get_git_branch() { | |
| git rev-parse --abbrev-ref HEAD 2>/dev/null | |
| } | |
| get_git_repo() { | |
| basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null | |
| } | |
| has_unstaged_changes() { | |
| if [[ -n $(git status --porcelain 2>/dev/null) ]]; then | |
| echo " +" | |
| fi | |
| } | |
| has_commits_to_push() { | |
| local branch=$(get_git_branch) | |
| if [[ -n $(git rev-list origin/"${branch}"..HEAD 2>/dev/null) ]]; then | |
| echo "↑" | |
| fi | |
| } | |
| has_commits_to_pull() { | |
| local branch=$(get_git_branch) | |
| local count=$(git rev-list HEAD..origin/"${branch}" --count 2>/dev/null) | |
| if [[ ${count} -gt 0 ]]; then | |
| echo "↓" | |
| fi | |
| } | |
| display_arrows() { | |
| local has_push=$(has_commits_to_push) | |
| local has_pull=$(has_commits_to_pull) | |
| if [[ -n ${has_push} || -n ${has_pull} ]]; then | |
| echo " ${has_push}${has_pull}" # Concatenate arrows without spaces | |
| elif [[ -n ${has_push} ]]; then | |
| echo " ${has_push}" | |
| elif [[ -n ${has_pull} ]]; then | |
| echo " ${has_pull}" | |
| else | |
| echo "" | |
| fi | |
| } | |
| update_prompt() { | |
| local branch=$(get_git_branch) | |
| local has_unstaged=$(has_unstaged_changes) | |
| local has_push=$(has_commits_to_push) | |
| local has_pull=$(has_commits_to_pull) | |
| local arrows=$(display_arrows) | |
| PROMPT="%F{cyan}[%D{%H:%M:%S}]%f %F{blue}%~%f %F{green}${branch}%f%F{red}${has_unstaged}%f%F{yellow}${arrows}%f λ " | |
| } | |
| # ---- carapace suggestions | |
| autoload -Uz compinit && compinit | |
| export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional | |
| zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' | |
| source <(carapace _carapace) | |
| zstyle ':completion:*' menu select | |
| zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' | |
| setopt MENU_COMPLETE # auto-select first match | |
| setopt AUTO_LIST # list choices on ambiguous completion | |
| setopt COMPLETE_IN_WORD # complete from both ends of a word | |
| # ---- end carapace suggestions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment