aboutsummaryrefslogtreecommitdiff
path: root/macos.local/flake/home/programs/zsh/init-extra.sh.org
blob: 8255ce10e847bcb2e3dd83057c2e9d985fb649fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#+title: ZSH Extra Initialization Code

Define optional aliases.
#+begin_src sh
  which lesspipe.sh &> /dev/null && export LESSOPEN="|lesspipe.sh %s"
  which eza &> /dev/null && alias ls=eza
#+end_src

Enable =fzf= extensions for =zsh=.
#+begin_src sh
  which zsh &> /dev/null && source <(fzf --zsh)
#+end_src

Enable git status in =zsh= prompt.
#+begin_src sh
  parse_git_dirty() {
    git_status="$(git status 2> /dev/null)"
    [[ "$git_status" =~ "use \"git push\" to publish your local commits" ]] && echo -n " %F{green}%f"
    [[ "$git_status" =~ "Changes to be committed:" ]] && echo -n " %F{magenta}%f"
    [[ "$git_status" =~ "Changes not staged for commit:" ]] && echo -n " %F{yellow}%f"
    [[ "$git_status" =~ "Untracked files:" ]] && echo -n " %F{red}%f"
  }
  setopt prompt_subst
  autoload -Uz vcs_info
  precmd () { vcs_info }
  zstyle ':vcs_info:*' formats ' %F{blue}%b%f' # git(main)
  PS1='%(?..%B%F{red}[%?%\]%f%b )%F{green}%20<...<%~%<<%f$vcs_info_msg_0_$(parse_git_dirty) $ '
#+end_src