if [ ! -d "$HOME/.zim" ] then git clone https://github.com/zimfw/zimfw $HOME/.zim source ~/.zim/zimfw.zsh install fi # Set editor default keymap to emacs bindkey -e stty -ixon #disable XON/XOFF, which breaks C-s # Prompt for spelling correction of commands. setopt CORRECT CORRECT_IGNORE="_*" # don't suggest completion functions # 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 # Escape % in commands zstyle ':zim:termtitle' format '%~:${${1:-zsh}//\\%/%%}' # Set window title before running a command zstyle ':zim:termtitle' hooks 'precmd' 'preexec' # 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) # Set zsh-autosuggestions highlight style ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=black,bold,underline" # 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 fi source ${ZIM_HOME}/init.zsh # Source aliases source $HOME/.aliases/general # Various Options unsetopt NOMATCH # turn off "no matches found" on glob failure # 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 # rehashes on bin change, might cause performance issues zstyle ':completion:*' rehash true # History Substring Search bindings (PageUp and PageDown) bindkey '^[[5~' history-substring-search-up bindkey '^[[6~' history-substring-search-down # 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) # 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 # 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 # Control-Backspace and Control-Delete bindkey '^H' backward-kill-word bindkey '5~' kill-word # 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