# zsh.functions for config_file ($HOME/.zsh.functions/*.zsh) source $config_file # zsh.before for config_file ($HOME/.zsh.before/*.zsh) source $config_file # Environment # # Smart URLs autoload -Uz url-quote-magic zle -N self-insert url-quote-magic # General setopt BRACE_CCL # Allow brace character class list expansion. setopt COMBINING_CHARS # Combine zero-length punctuation characters (accents) # with the base character. setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'. unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed. # Jobs setopt LONG_LIST_JOBS # List jobs in the long format by default. setopt AUTO_RESUME # Attempt to resume existing job before creating a new process. setopt NOTIFY # Report status of background jobs immediately. unsetopt BG_NICE # Don't run all background jobs at a lower priority. unsetopt HUP # Don't kill jobs on shell exit. unsetopt CHECK_JOBS # Don't report on jobs when shell exit. ## Termcap #if zstyle -t ':prezto:environment:termcap' color; then # export LESS_TERMCAP_mb=$'\E[01;31m' # Begins blinking. # export LESS_TERMCAP_md=$'\E[01;31m' # Begins bold. # export LESS_TERMCAP_me=$'\E[0m' # Ends mode. # export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode. # export LESS_TERMCAP_so=$'\E[00;47;30m' # Begins standout-mode. # export LESS_TERMCAP_ue=$'\E[0m' # Ends underline. # export LESS_TERMCAP_us=$'\E[01;32m' # Begins underline. #fi # Terminal # # Do not override precmd/preexec; append to the hook array. autoload -Uz add-zsh-hook # Sets the tab and window titles before the prompt is displayed. add-zsh-hook precmd _terminal-set-titles-with-path # Sets the tab and window titles before command execution. add-zsh-hook preexec _terminal-set-titles-with-command # Editor # # Beep on error in line editor. setopt BEEP # Treat these characters as part of a word. WORDCHARS='*?_-.[]~&;!#$%^(){}<>' # Use human-friendly identifiers. zmodload zsh/terminfo typeset -gA key_info key_info=( 'Control' '\C-' 'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd' 'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc' 'Escape' '\e' 'Meta' '\M-' 'Backspace' "^?" 'Delete' "^[[3~" 'F1' "$terminfo[kf1]" 'F2' "$terminfo[kf2]" 'F3' "$terminfo[kf3]" 'F4' "$terminfo[kf4]" 'F5' "$terminfo[kf5]" 'F6' "$terminfo[kf6]" 'F7' "$terminfo[kf7]" 'F8' "$terminfo[kf8]" 'F9' "$terminfo[kf9]" 'F10' "$terminfo[kf10]" 'F11' "$terminfo[kf11]" 'F12' "$terminfo[kf12]" 'Insert' "$terminfo[kich1]" 'Home' "$terminfo[khome]" 'PageUp' "$terminfo[kpp]" 'End' "$terminfo[kend]" 'PageDown' "$terminfo[knp]" 'Up' "$terminfo[kcuu1]" 'Left' "$terminfo[kcub1]" 'Down' "$terminfo[kcud1]" 'Right' "$terminfo[kcuf1]" 'BackTab' "$terminfo[kcbt]" ) # Set empty $key_info values to an invalid UTF-8 sequence to induce silent # bindkey failure. for key in "${(k)key_info[@]}"; do if [[ -z "$key_info[$key]" ]]; then key_info[$key]='�' fi done # Allow command line editing in an external editor. autoload -Uz edit-command-line zle -N edit-command-line # Reset to default key bindings. bindkey -d # # Vi Key Bindings # # Edit command in an external editor. bindkey -M vicmd "v" edit-command-line # Undo/Redo bindkey -M vicmd "u" undo bindkey -M vicmd "$key_info[Control]R" redo if (( $+widgets[history-incremental-pattern-search-backward] )); then bindkey -M vicmd "?" history-incremental-pattern-search-backward bindkey -M vicmd "/" history-incremental-pattern-search-forward else bindkey -M vicmd "?" history-incremental-search-backward bindkey -M vicmd "/" history-incremental-search-forward fi # # Emacs and Vi Key Bindings # for keymap in 'emacs' 'viins'; do bindkey -M "$keymap" "$key_info[Home]" beginning-of-line bindkey -M "$keymap" "$key_info[End]" end-of-line bindkey -M "$keymap" "$key_info[Insert]" overwrite-mode bindkey -M "$keymap" "$key_info[Delete]" delete-char bindkey -M "$keymap" "$key_info[Backspace]" backward-delete-char bindkey -M "$keymap" "$key_info[Left]" backward-char bindkey -M "$keymap" "$key_info[Right]" forward-char # Expand history on space. bindkey -M "$keymap" ' ' magic-space # Clear screen. bindkey -M "$keymap" "$key_info[Control]L" clear-screen # Expand command name to full path. for key in "$key_info[Escape]"{E,e} bindkey -M "$keymap" "$key" expand-cmd-path # Duplicate the previous word. for key in "$key_info[Escape]"{M,m} bindkey -M "$keymap" "$key" copy-prev-shell-word # Use a more flexible push-line. for key in "$key_info[Control]Q" "$key_info[Escape]"{q,Q} bindkey -M "$keymap" "$key" push-line-or-edit # Bind Shift + Tab to go to the previous menu item. bindkey -M "$keymap" "$key_info[BackTab]" reverse-menu-complete # Complete in the middle of word. bindkey -M "$keymap" "$key_info[Control]I" expand-or-complete # Insert 'sudo ' at the beginning of the line. bindkey -M "$keymap" "$key_info[Control]X$key_info[Control]S" prepend-sudo done # Set the key layout to vi mode bindkey -v unset key{,map,bindings} # History # # The path to the history file HISTFILE="${ZDOTDIR:-$HOME}/.zhistory" # The maximum number of events to save in the internal history. HISTSIZE=10000 # The maximum number of events to save in the history file. SAVEHIST=10000 # Treat the '!' character specially during expansion. setopt BANG_HIST # Write the history file in the ':start:elapsed;command' format. setopt EXTENDED_HISTORY # Write to the history file immediately, not when the shell exits. setopt INC_APPEND_HISTORY # Share history between all sessions. setopt SHARE_HISTORY # Expire a duplicate event first when trimming history. setopt HIST_EXPIRE_DUPS_FIRST # Do not record an event that was just recorded again. setopt HIST_IGNORE_DUPS # Delete an old recorded event if a new event is a duplicate. setopt HIST_IGNORE_ALL_DUPS # Do not display a previously found event. setopt HIST_FIND_NO_DUPS # Do not record an event starting with a space. setopt HIST_IGNORE_SPACE # Do not write a duplicate event to the history file. setopt HIST_SAVE_NO_DUPS # Do not execute immediately upon history expansion. setopt HIST_VERIFY # Beep when accessing non-existent history. setopt HIST_BEEP # Directory # # Auto changes to a directory without typing cd. setopt AUTO_CD # Push the old directory onto the stack on cd. setopt AUTO_PUSHD # Do not store duplicates in the stack. setopt PUSHD_IGNORE_DUPS # Do not print the directory stack after pushd or popd. setopt PUSHD_SILENT # Push to home directory when no argument is given. setopt PUSHD_TO_HOME # Change directory to a path stored in a variable. setopt CDABLE_VARS # Auto add variable-stored paths to ~ list. setopt AUTO_NAME_DIRS # Write to multiple descriptors. setopt MULTIOS # Use extended globbing syntax. setopt EXTENDED_GLOB # Do not overwrite existing files with > and >>. # Use >! and >>! to bypass. unsetopt CLOBBER # Externals # # TODO: Add conditional to check for availability # syntax-highlighting source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # history-substring-search source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh # Vi bindkey -M vicmd "k" history-substring-search-up bindkey -M vicmd "j" history-substring-search-down # Emacs and Vi for keymap in 'emacs' 'viins'; do bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down done # zsh.after # for config_file ($HOME/.zsh.after/*.zsh) source $config_file # Prompt # # Load and execute the prompt theming system. autoload -Uz promptinit && promptinit prompt dvzrv unset prompt_argv