~tommoa/dots

ref: 21e0562f16c6c9c237c8b8efd248d4bae08a4adf dots/.zshrc -rw-r--r-- 2.2 KiB
21e0562fTom Almeida nvim(treesitter): Don't do indentation 4 months ago
                                                                                
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Only zsh specific things will be in this file

# Source .env
source ~/.env

autoload -U colors && colors

prompt_git() {
    # Because ANSI colour codes are borked on ZSH, if we use PS1 it shifts the
    # RPROMPT, so we need a custom function
    # To see a fully POSIX version of this function, see ~/.env

    if [ "${GIT_PROMPT}" = "1" ] && git rev-parse --is-inside-work-tree -q >/dev/null 2>&1; then
        eval $(git diff-files --numstat -r 2>/dev/null | awk '{add+=$1; remove+=$2} END {printf "num_added='%d';num_removed='%d';total='%d';", add, remove, NR}')
        totals="";
        if [ "${total}" -gt 0 ]; then
            totals=":%%F{blue}${total}"
            [ "${num_added}" -gt 0 ] && totals="${totals}%%F{85}+${num_added}"
            [ "${num_removed}" -gt 0 ] && totals="${totals}%%F{red}-${num_removed}"
        fi
        printf "%%B[%%F{red}$(git symbolic-ref --short -q HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)%%f${totals}%%f] %%b"
    fi
}
setopt prompt_subst
PROMPT=%F{85}%B%n${SSH_CLIENT:+%F{red}@%F{cyan}%U%m%u}%f:%F{75}%~%f\#%b\ \$(prompt_git)
RPROMPT=%T

# zsh options - see zshoptions(1)
setopt HIST_IGNORE_DUPS HIST_IGNORE_SPACE HIST_NO_STORE INTERACTIVE_COMMENTS
setopt LONG_LIST_JOBS PRINT_EXIT_VALUE RC_QUOTES
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

# key bindings
# tab completion
bindkey '^[=' expand-cmd-path
# arrow keys
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end
bindkey "${terminfo[kcuu1]}" history-beginning-search-backward-end
bindkey "${terminfo[kcud1]}" history-beginning-search-forward-end
# ^U kills the entire line, not just back from cursor
bindkey '^U' kill-whole-line
bindkey '^R' history-incremental-search-backward

bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line

# Disable core dumps
limit coredumpsize 0

zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' menu select=long

ZLS_COLOURS="${(s.:.)LS_COLORS}"
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit

setopt auto_cd
stty -ixon
export GIT_PROMPT=1