2019-12-25 21:27:17 -05:00
|
|
|
if [ ! -d "$HOME/.zim" ]
|
|
|
|
then
|
2020-01-07 14:22:04 -05:00
|
|
|
git clone https://github.com/zimfw/zimfw $HOME/.zim
|
2019-12-25 21:27:17 -05:00
|
|
|
source ~/.zim/zimfw.zsh install
|
|
|
|
fi
|
2016-01-22 19:06:27 -05:00
|
|
|
|
2019-12-25 21:27:17 -05:00
|
|
|
# Set editor default keymap to emacs
|
|
|
|
bindkey -e
|
|
|
|
stty -ixon #disable XON/XOFF, which breaks C-s
|
2016-02-15 11:20:39 -05:00
|
|
|
|
2019-12-25 21:27:17 -05:00
|
|
|
# Prompt for spelling correction of commands.
|
|
|
|
setopt CORRECT
|
|
|
|
CORRECT_IGNORE="_*" # don't suggest completion functions
|
2016-02-15 11:20:39 -05:00
|
|
|
|
2019-12-25 21:27:17 -05:00
|
|
|
# Customize spelling correction prompt.
|
|
|
|
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
|
|
|
|
|
|
|
# Remove path separator from WORDCHARS.
|
|
|
|
WORDCHARS=${WORDCHARS//[\/]}
|
|
|
|
|
|
|
|
# Set window title format
|
2023-01-31 15:36:04 -05:00
|
|
|
# Escape % in commands
|
|
|
|
zstyle ':zim:termtitle' format '%~:${${1:-zsh}//\\%/%%}'
|
2020-02-20 12:48:11 -05:00
|
|
|
# Set window title before running a command
|
|
|
|
zstyle ':zim:termtitle' hooks 'precmd' 'preexec'
|
2019-12-25 21:27:17 -05:00
|
|
|
|
|
|
|
# Append `../` to your input for each `.` you type after an initial `..`
|
|
|
|
zstyle ':zim:input' double-dot-expand yes
|
|
|
|
|
|
|
|
# Set what highlighters will be used.
|
|
|
|
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
|
|
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
|
|
|
|
|
2019-12-26 19:20:49 -05:00
|
|
|
# Set zsh-autosuggestions highlight style
|
|
|
|
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=black,bold,underline"
|
2019-12-25 21:27:17 -05:00
|
|
|
|
|
|
|
# Initialize Zim modules
|
|
|
|
if [[ ${ZIM_HOME}/init.zsh -ot ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
|
|
|
|
# Update static initialization script if it's outdated, before sourcing it
|
|
|
|
source ${ZIM_HOME}/zimfw.zsh init -q
|
2016-12-02 12:49:33 -05:00
|
|
|
fi
|
2019-12-25 21:27:17 -05:00
|
|
|
source ${ZIM_HOME}/init.zsh
|
|
|
|
|
|
|
|
# Source aliases
|
|
|
|
source $HOME/.aliases/general
|
|
|
|
|
|
|
|
# Various Options
|
|
|
|
unsetopt NOMATCH # turn off "no matches found" on glob failure
|
2016-12-02 12:49:33 -05:00
|
|
|
|
2020-01-12 20:38:39 -05:00
|
|
|
# Remove older command from the history if a duplicate is to be added.
|
|
|
|
setopt HIST_IGNORE_ALL_DUPS
|
|
|
|
unsetopt SHARE_HISTORY # don't share history between terminals
|
|
|
|
setopt INC_APPEND_HISTORY
|
|
|
|
|
2019-12-25 21:27:17 -05:00
|
|
|
# rehashes on bin change, might cause performance issues
|
|
|
|
zstyle ':completion:*' rehash true
|
2016-12-02 12:50:17 -05:00
|
|
|
|
2017-09-02 13:47:07 -04:00
|
|
|
# History Substring Search bindings (PageUp and PageDown)
|
2016-12-02 12:50:17 -05:00
|
|
|
bindkey '^[[5~' history-substring-search-up
|
|
|
|
bindkey '^[[6~' history-substring-search-down
|
|
|
|
|
2024-08-28 11:37:46 -04:00
|
|
|
# fine word navigation
|
|
|
|
backward-word-fine() WORDCHARS='' zle .backward-word
|
|
|
|
forward-word-fine() WORDCHARS='' zle .forward-word
|
|
|
|
zle -N backward-word-fine
|
|
|
|
zle -N forward-word-fine
|
|
|
|
bindkey '^[F' forward-word-fine
|
|
|
|
bindkey '^[B' backward-word-fine
|
|
|
|
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS+=(forward-word-fine backward-word-fine)
|
|
|
|
|
2023-04-11 14:01:54 -04:00
|
|
|
# equivalents of eponymous Emacs functions
|
|
|
|
# from https://unix.stackexchange.com/a/595157
|
|
|
|
delete-horizontal-space() {
|
|
|
|
emulate -L zsh
|
|
|
|
set -o extendedglob
|
|
|
|
LBUFFER=${LBUFFER%%[[:blank:]]##}
|
|
|
|
RBUFFER=${RBUFFER##[[:blank:]]##}
|
|
|
|
}
|
|
|
|
zle -N delete-horizontal-space
|
|
|
|
bindkey '\e\\' delete-horizontal-space
|
|
|
|
just-one-space() {
|
|
|
|
delete-horizontal-space
|
|
|
|
LBUFFER="$LBUFFER "
|
|
|
|
}
|
|
|
|
zle -N just-one-space
|
|
|
|
bindkey '\e ' just-one-space
|
|
|
|
|
2016-12-02 12:50:17 -05:00
|
|
|
# Inserts 'sudo ' at the beginning of the line.
|
|
|
|
function prepend-sudo() {
|
|
|
|
if [[ "$BUFFER" != su(do|)\ * ]]; then
|
|
|
|
BUFFER="sudo $BUFFER"
|
|
|
|
(( CURSOR += 5 ))
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
zle -N prepend-sudo
|
|
|
|
bindkey "^X^S" prepend-sudo
|
2016-02-15 11:20:51 -05:00
|
|
|
|
2017-09-02 13:46:36 -04:00
|
|
|
# Control-Backspace and Control-Delete
|
2016-12-02 12:50:17 -05:00
|
|
|
bindkey '^H' backward-kill-word
|
2017-09-02 13:46:36 -04:00
|
|
|
bindkey '5~' kill-word
|
2019-12-25 21:27:17 -05:00
|
|
|
|
|
|
|
# Auto start tmux if a remote connection
|
|
|
|
if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -n "$SSH_TTY" ]]
|
|
|
|
then
|
|
|
|
# Attach only to the 'auto' session
|
|
|
|
exec tmux new-session -A -s 'auto'
|
|
|
|
fi
|