summaryrefslogtreecommitdiff
path: root/zsh/.zshrc
blob: b3e72f0707b0eb7b6347e6b60fdb25cdf90c3da1 (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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
setopt inc_append_history share_history histignorealldups

if [[ ${INSIDE_EMACS} == *comint* ]]; then
    PAGER=cat
    TERM=xterm-256color
    unsetopt zle
fi
if [[ ${TERM} = "dumb" ]]; then
  # This fixes TRAMP.
  unsetopt zle
  PS1='$ '
  return 0
fi

eval "$(starship init zsh)"

# Resources:
# https://github.com/mika/zsh-pony

bindkey -e

autoload -Uz compinit; compinit
autoload -Uz promptinit; promptinit

zstyle ':completion:*' menu select
zstyle ':completion::complete:*' gain-privileges 1
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}

# Don't skip over symbols, e.g., when deleting a word from a path.
WORDCHARS=''

# source ~/.zsh/powerlevel10k/powerlevel10k.zsh-theme

# cd to a directory used as a commant
setopt autocd

# commands starting with # are treated as comments
setopt interactivecomments

alias ls="ls --color"
alias e="emacsclient -n"
# Never got used to this.
# (( $+commands[exa] )) && alias ls="exa"

if (( $+commands[fzf] )); then
  if (( $+commands[fzf-share] )); then
    # Nixos
    source "$(fzf-share)/completion.zsh"
    source "$(fzf-share)/key-bindings.zsh"
  else
    # Debian
    source /usr/share/doc/fzf/examples/completion.zsh
    source /usr/share/doc/fzf/examples/key-bindings.zsh
  fi
fi

if (( $+commands[zoxide] )); then
 eval "$(zoxide init zsh)"
fi

# Issues when typing 'ssh root@' with fast syntax hilighting.
if [[ -n ${INSIDE_EMACS} ]]; then
  source ~/.zsh/syntax-highlighting/zsh-syntax-highlighting.zsh
fi

# allow editing of command line
autoload -U edit-command-line
zle -N edit-command-line
bindkey "^V" edit-command-line

function get-parent-dir() {
  words=(${(z)LBUFFER})
  if [[ "${words[${#words}]}" = /* ]]; then
    # There is already a path thing here.
    words[${#words}]="${words[${#words}]:h}/"  # Parent directory.
  else
    words=($words $PWD)
  fi
  LBUFFER="${words[@]}"
}
zle -N get-parent-dir
bindkey "^[u" get-parent-dir

source ~/.zshrc.local

(( $+commands[direnv] )) && eval "$(direnv hook zsh)"