diff options
Diffstat (limited to '.config')
| -rw-r--r-- | .config/zsh/.zshrc | 82 |
1 files changed, 29 insertions, 53 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 44fa2c1..4bb0301 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -5,62 +5,38 @@ clp(){ yes | paru -Scc } -git_status(){ -if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then - gbranch=$(git branch --show-current) - - gstatus="" - gadded="no" - gwaiting="no" - - waiting_commits=$(git rev-list @{u}..@ --count 2> /dev/null) - - if [[ $waiting_commits -gt 0 ]]; then - gwaiting="yes" - gstatus+="⇡" - fi - - for i in $(git status --porcelain | tac); do - i=$(echo "$i" | sed 's/ *$//; s/^ *//' | cut -f1 -d " ") - - gsymbol="" - if [[ "$i" == "A"* ]]; then - if [[ $gadded == "no" ]]; then - gadded="yes" - gstatus+="+" - fi - i="${i:1}" +autoload -Uz vcs_info + +# enable only git +zstyle ':vcs_info:*' enable git + +# setup a hook that runs before every ptompt. +precmd_vcs_info() { vcs_info } +precmd_functions+=( precmd_vcs_info ) + +# add a function to check for untracked files in the directory. +# from https://github.com/zsh-users/zsh/blob/master/Misc/vcs_info-examples +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +# ++vi-git-untracked(){ + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ + git status --porcelain | grep '??' &> /dev/null ; then + # This will show the marker if there are any untracked files in repo. + # If instead you want to show the marker only if there are untracked + # files in $PWD, use: + #[[ -n $(git ls-files --others --exclude-standard) ]] ; then + hook_com[staged]+='!' # signify new files with a bang fi - - if [[ "$i" == "??" ]]; then - gsymbol="?" - elif [[ "$i" == "M" ]]; then - gsymbol="!" - elif [[ "$i" == "D" ]]; then - gsymbol="✘" - elif [[ "$i" == "R" ]]; then - gsymbol=">" - elif [[ "$i" == "C" ]]; then - gsymbol=">" - else - gsymbol="" - fi - - if [[ "$gstatus" == *"$gsymbol"* ]]; then - continue - else - gstatus+="$gsymbol" - fi - done - - # Output in the format: branch [status] - echo -n "$gbranch [$gstatus] " -else - echo -n "" -fi } -PS1='%{$fg[brightwhite]%}%n@%m %{$fg[yellow]%}%~ %{$fg[magenta]%}$(git_status)%{$fg[white]%}$ %{$reset_color%}' +zstyle ':vcs_info:*' check-for-changes true +# zstyle ':vcs_info:git:*' formats " %r/%S %b %m%u%c " +zstyle ':vcs_info:git:*' formats " %{$fg[blue]%}(%{$fg[red]%}%m%u%c%{$fg[yellow]%}%{$fg[magenta]%} %b%{$fg[blue]%})" + +# format our main prompt for hostname current folder, and permissions. +PROMPT="%B%{$fg[blue]%}[%{$fg[white]%}%n%{$fg[red]%}@%{$fg[white]%}%m%{$fg[blue]%}] %(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )%{$fg[cyan]%}%c%{$reset_color%}" +# PROMPT="%{$fg[green]%}%n@%m %~ %{$reset_color%}%#> " +PROMPT+="\$vcs_info_msg_0_ " setopt autocd # Automatically cd into typed directory. stty stop undef # Disable ctrl-s to freeze terminal. setopt interactive_comments |