-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc.tmpl
90 lines (78 loc) · 3.59 KB
/
dot_zshrc.tmpl
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
# vim: set filetype=bash:
echo "*** sourcing ~/.zshrc ***"
{{template "interactive_shell.tmpl" .}}
# zsh specific history settings.
export SAVEHIST=$HISTSIZE
setopt append_history # Immediately append history instead of overwriting
setopt inc_append_history # Write to history file immediately, not when shell quits
setopt no_extended_history # Disable extended history format for bash compatibility.
setopt no_share_history # Also necessary to disable extended history format.
setopt hist_ignore_all_dups # If a new command is a duplicate, remove the older one
alias h="fc -R && history 1" # List all history (like bash) from all shell instances.
# Tab completion
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinit
zstyle ':completion:*' rehash true # automatically find new executables in the $PATH
# Fix slow git tab completion, see https://stackoverflow.com/a/9810485/1136455
__git_files () {
_wanted files expl 'local files' _files
}
bindkey -v # vi command-line editing
setopt interactive_comments # allow # comments in shell; good for copy/paste
export BLOCK_SIZE="'1" # Add commas to file sizes
typeset -U path # keep duplicates out of the path
setopt extended_glob # extended globbing. Allows using regular expressions with *
setopt autocd # if only directory path is entered, cd there.
#
# Install zsh community projects (https://github.com/zsh-users)
#
# If not already installed then install a zsh-users project and then load it.
# $1 is the zsh-users project Github repository URL.
function load-zsh-users() {
local url="$1"
local dir="$HOME/.zsh/$(basename $1)"
local file="$dir/$(basename $1).zsh"
if [ ! -d $dir ]; then
git clone $url $dir
fi
source $file
}
load-zsh-users https://github.com/zsh-users/zsh-autosuggestions
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=249" # See https://coderwall.com/p/pb1uzq/z-shell-colors
# Mapping Ctrl+Enter to autosuggest-execute is problematic (https://stackoverflow.com/a/45714460/1136455)
bindkey '^@' autosuggest-execute # Ctrl+Space executes current suggestion
load-zsh-users https://github.com/zsh-users/zsh-syntax-highlighting
load-zsh-users https://github.com/zsh-users/zsh-history-substring-search
{{if eq .chezmoi.osRelease.id "manjaro"}}
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
{{else}}
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
{{end}}
export HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=true
{{if or (eq .chezmoi.osRelease.id "manjaro") (eq .chezmoi.osRelease.id "ubuntu")}}
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/srackham/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/srackham/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/srackham/miniconda3/etc/profile.d/conda.sh"
else
if [[ ":$PATH:" != *":/home/srackham/miniconda3/bin:"* ]]; then
export PATH="/home/srackham/miniconda3/bin:$PATH"
fi
fi
fi
unset __conda_setup
# <<< conda initialize <<<
{{end}}
# Set up fzf key bindings and fuzzy completion.
{{/*
NOTE: fzf `--bash`, `--zsh` options to install key bindings and completions are only available in fzf 0.48.0 or later -- https://github.com/junegunn/fzf#using-linux-package-managers).
*/}}
eval "$(fzf --zsh)"
# Set up zoxide and alias to cd and cdi.
eval "$(zoxide init --cmd cd zsh)"