blob: 35b89f1a601ab367688b1a404eb881b21af86a35 (
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
|
#!/bin/zsh
export ZSH_COMPDUMP="$XDG_CACHE_HOME/zcompdump"
# do not glob for calculator command
aliases[=]="noglob ="
# color aliases
alias ls='ls --color=auto'
alias grep='grep --color=auto'
# completion
autoload -U compinit
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' special-dirs true
setopt auto_menu # show completion menu when spamming <tab>
setopt complete_in_word
setopt always_to_end # move cursor to end of word after completion
setopt auto_cd # cd if the command is a valid path
WORDCHARS="${WORDCHARS:gs/\//}" # remove '/' from WORDCHARS
compinit -d "$ZSH_COMPDUMP"
# history
export HISTFILE="$XDG_DATA_HOME/zsh/history"
export HISTSIZE=10000000
export SAVEHIST=10000000
setopt share_history
# keybinds
bindkey -e # emacs bindings
bindkey '^[[Z' reverse-menu-complete
# prompt
unset PROMPT
setopt PROMPT_SUBST
prompt_segment() {
content="$1"
[ -z "$content" ] && return
echo "%{\e[90m%}${content}%{\e[30m%} -> %{\e[0m%}"
}
prompt_mod_git_info() {
git rev-parse --is-inside-work-tree 1> /dev/null 2> /dev/null || return
prompt_segment "git $(git rev-parse --abbrev-ref HEAD)"
}
# only display hostname in prompt if connected over SSH
[ -n "$SSH_CLIENT" ] && PROMPT+="$(prompt_segment '%m')"
# working directory
PROMPT+="$(prompt_segment '%c')"
# git info (if in repo)
PROMPT+="\$(prompt_mod_git_info)"
|