Repository navigation
Expand file tree
/
Copy pathdot_zshrc.tmpl
More file actions
112 lines (102 loc) · 4.32 KB
/
Copy pathdot_zshrc.tmpl
File metadata and controls
112 lines (102 loc) · 4.32 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# vim: set filetype=zsh :
# NOTE: Do not edit this file directly
# Use: chezmoi edit ~/.zshrc
# Or after editing, run: chezmoi re-add ~/.zshrc
umask 0022 >/dev/null 2>&1
[[ $- != *i* ]] && return
## A simple prompt
# PROMPT='[%n@%m %~] > '
__shell_specific() {
# Set Up Prompt
# 14 = bright cyan, 10 = bright green, 12 = bright blue
PROMPT=""
PROMPT="${PROMPT}${PRE_PROMPT}" # Add (zsh) if running in a zsh subshell with runzsh
PROMPT="${PROMPT}%B" # Bold the prompt
PROMPT="${PROMPT}[" # Start with a bracket
PROMPT="${PROMPT}%F{14}%n%f" # Show username in cyan
PROMPT="${PROMPT}@" # @
PROMPT="${PROMPT}%F{10}%m%f" # Show host in green
PROMPT="${PROMPT} " # space
PROMPT="${PROMPT}%F{12}%(3~,${dots}/,)%2~%f" # Show directories in blue
PROMPT="${PROMPT}]" # Close bracket
PROMPT="${PROMPT}${subshell}" # If in a subshell (chezmoi) show a plus
# Git stuff
command -v __git_ps1 >/dev/null 2>&1 && PROMPT="$PROMPT\$(__git_ps1 \" (%%F{${git_c}}${git_s}%%f %s)\" 2>&1|grep -v 'Permission denied')"
PROMPT="${PROMPT} %F{blue}%(!.#.${pchar})%f" # Show prompt in blue
PROMPT="${PROMPT}%b" # End bold
PROMPT="${PROMPT} " # Trailing space
vi_ins="%F{green}[I]%f"
vi_cmd="%F{blue}[N]%f"
vi_mode=$vi_ins
function zle-line-init zle-keymap-select {
vi_mode="${${KEYMAP/vicmd/${vi_cmd}}/(main|viins)/${vi_ins}}"
zle reset-prompt
}
function zle-line-finish { vi_mode=$vi_ins ; }
zle -N zle-line-init
zle -N zle-keymap-select
zle -N zle-line-finish
RPROMPT=""
RPROMPT="${RPROMPT}%(?..%F{red}(\$?%)%f )" # Show error exit code in red
RPROMPT="${RPROMPT}\${vi_mode}" # Show cli vi mode state
autoload -U colors && colors
autoload -U edit-command-line && zle -N edit-command-line
autoload compdef
autoload zmv
if [[ -r /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh ]]; then
. /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
elif [[ -r /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
. /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
fi
if [[ -r /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh ]]; then
. /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
elif [[ -r /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
. /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
bindkey -M vicmd j vi-down-line-or-history
bindkey -M vicmd k vi-up-line-or-history
bindkey -v '^?' backward-delete-char # Allow backspace character to work
bindkey -M vicmd '^v' edit-command-line
bindkey -M viins '^y' autosuggest-execute
bindkey " " magic-space
autoload -Uz compinit && compinit
if [ -r "$HOME"/.config/zsh/plugins/fzf-tab/fzf-tab.plugin.zsh ]; then
. "$HOME"/.config/zsh/plugins/fzf-tab/fzf-tab.plugin.zsh
zstyle ":fzf-tab:*" use-fzf-default-opts yes
zstyle ":fzf-tab:complete:cd:*" fzf-preview "ls --color=always \${realpath}"
zstyle ':fzf-tab:*' query-string input
fi
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list ''
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'm:{a-z}={A-Z} r:|[._-]=* r:|=*'
setopt append_history inc_append_history share_history hist_ignore_space
setopt auto_cd cd_silent auto_pushd pushd_silent rmstarsilent
setopt no_hup no_check_jobs prompt_subst interactive_comments no_match
setopt correct
# CORRECT_IGNORE=
# setopt correct_all
# CORRECT_IGNORE_FILE=
stty stop undef
bindkey -v
alias reprofile='. $HOME/.zshrc'
# Install zoxide on OpenBSD with: cargo install zoxide --locked
if command -v zoxide >/dev/null 2>&1; then
eval "$(zoxide init zsh)"
alias cd=z
fi
# . <(niri completions zsh)
# if command -v starship >/dev/null 2>&1; then
# eval "$(starship init zsh)"
# fi
if [[ -z "$ATUIN_SESSION" ]] && ! typeset -f fzf-history-widget &> /dev/null; then
if command -v atuin >/dev/null 2>&1; then
eval "$(atuin init --disable-ai --disable-up-arrow zsh)"
elif command -v fzf >/dev/null 2>&1; then
. <(fzf --zsh)
bindkey -M viins '^p' history-search-backward
bindkey -M viins '^n' history-search-forward
fi
fi
}
[ -r "$HOME"/.shellrc ] && . "$HOME"/.shellrc
true