mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 08:41:43 +00:00
The functions directory should only hold functions.
This commit is contained in:
@ -1,109 +0,0 @@
|
||||
setopt correct # Correct commands.
|
||||
setopt correct_all # Correct all arguments.
|
||||
|
||||
# The 'ls' Family
|
||||
if check-bool "$COLOR"; then
|
||||
if [[ -f "$HOME/.dir_colors" ]] && ( (( $+commands[dircolors] )) || ( (( $+plugins[(er)gnu-utils] )) && (( $+commands[gdircolors] )) ) ); then
|
||||
eval $("${commands[dircolors]:-$commands[gdircolors]}" "$HOME/.dir_colors")
|
||||
alias ls='ls -hF --group-directories-first --color=auto'
|
||||
else
|
||||
export CLICOLOR=1
|
||||
export LSCOLORS="exfxcxdxbxegedabagacad"
|
||||
alias ls='ls -G -F'
|
||||
fi
|
||||
fi
|
||||
|
||||
alias l='ls -1A' # Show files in one column.
|
||||
alias ll='ls -lh' # Show human readable.
|
||||
alias la='ls -lhA' # Show hidden files.
|
||||
alias lx='ls -lhXB' # Sort by extension.
|
||||
alias lk='ls -lhSr' # Sort by size, biggest last.
|
||||
alias lc='ls -lhtcr' # Sort by and show change time, most recent last.
|
||||
alias lu='ls -lhtur' # Sort by and show access time, most recent last.
|
||||
alias lt='ls -lhtr' # Sort by date, most recent last.
|
||||
alias lm='ls -lha | more' # Pipe through 'more'.
|
||||
alias lr='ls -lhR' # Recursive ls.
|
||||
alias sl='ls' # I often screw this up.
|
||||
|
||||
# General
|
||||
alias _='sudo'
|
||||
alias b="$BROWSER"
|
||||
alias cd='nocorrect cd'
|
||||
alias cp='nocorrect cp -i'
|
||||
alias df='df -kh'
|
||||
alias du='du -kh'
|
||||
alias e="$EDITOR"
|
||||
alias find='noglob find'
|
||||
alias gcc='nocorrect gcc'
|
||||
alias history='fc -l 1'
|
||||
alias ln='nocorrect ln -i'
|
||||
alias locate='noglob locate'
|
||||
alias man='nocorrect man'
|
||||
alias mkdir='nocorrect mkdir -p'
|
||||
alias mv='nocorrect mv -i'
|
||||
alias po='popd'
|
||||
alias pu='pushd'
|
||||
alias rake='noglob rake'
|
||||
alias rm='nocorrect rm -i'
|
||||
alias scp='nocorrect scp'
|
||||
alias type='type -a'
|
||||
alias v="$PAGER"
|
||||
|
||||
# Mac OS X
|
||||
if [[ "$OSTYPE" != darwin* ]]; then
|
||||
alias open='xdg-open'
|
||||
alias get='wget --continue --progress=bar'
|
||||
|
||||
if (( $+commands[xclip] )); then
|
||||
alias pbcopy='xclip -selection clipboard -in'
|
||||
alias pbpaste='xclip -selection clipboard -out'
|
||||
fi
|
||||
|
||||
if (( $+commands[xsel] )); then
|
||||
alias pbcopy='xsel --clipboard --input'
|
||||
alias pbpaste='xsel --clipboard --output'
|
||||
fi
|
||||
else
|
||||
alias get='curl --continue-at - --location --progress-bar --remote-name'
|
||||
fi
|
||||
|
||||
alias o='open'
|
||||
alias pbc='pbcopy'
|
||||
alias pbp='pbpaste'
|
||||
|
||||
# Top
|
||||
if (( $+commands[htop] )); then
|
||||
alias top=htop
|
||||
else
|
||||
alias topm='top -o vsize'
|
||||
alias topc='top -o cpu'
|
||||
fi
|
||||
|
||||
# Diff/Make
|
||||
if check-bool "$COLOR"; then
|
||||
if (( $+commands[colordiff] )); then
|
||||
alias diff='colordiff -u'
|
||||
compdef colordiff=diff
|
||||
elif (( $+commands[git] )); then
|
||||
function diff() {
|
||||
git --no-pager diff --color=always --no-ext-diff --no-index "$@";
|
||||
}
|
||||
compdef _git diff=git-diff
|
||||
else
|
||||
alias diff='diff -u'
|
||||
fi
|
||||
|
||||
if (( $+commands[colormake] )); then
|
||||
alias make='colormake'
|
||||
compdef colormake=make
|
||||
fi
|
||||
fi
|
||||
|
||||
# Miscellaneous
|
||||
(( $+commands[ack] )) && alias afind='ack -il'
|
||||
(( $+commands[ebuild] )) && alias ebuild='nocorrect ebuild'
|
||||
(( $+commands[gist] )) && alias gist='nocorrect gist'
|
||||
(( $+commands[heroku] )) && alias heroku='nocorrect heroku'
|
||||
(( $+commands[hpodder] )) && alias hpodder='nocorrect hpodder'
|
||||
(( $+commands[mysql] )) && alias mysql='nocorrect mysql'
|
||||
|
@ -1,130 +0,0 @@
|
||||
# Dumb terminals lack support.
|
||||
if [[ "$TERM" == 'dumb' ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
setopt complete_in_word # Complete from both ends of a word.
|
||||
setopt always_to_end # Move cursor to the end of a completed word.
|
||||
setopt path_dirs # Perform path search even on command names with slashes.
|
||||
setopt auto_menu # Show completion menu on a succesive tab press.
|
||||
setopt auto_list # Automatically list choices on ambiguous completion.
|
||||
setopt auto_param_slash # If completed parameter is a directory, add a trailing slash.
|
||||
unsetopt menu_complete # Do not autoselect the first completion entry.
|
||||
unsetopt flow_control # Disable start/stop characters in shell editor.
|
||||
|
||||
# Treat these characters as part of a word.
|
||||
WORDCHARS='*?_-.[]~&;!#$%^(){}<>'
|
||||
|
||||
# Use caching to make completion for cammands such as dpkg and apt usable.
|
||||
zstyle ':completion::complete:*' use-cache on
|
||||
zstyle ':completion::complete:*' cache-path "$HOME/.zcache"
|
||||
|
||||
# Case-insensitive (all), partial-word, and then substring completion.
|
||||
if check-bool "$CASE_SENSITIVE"; then
|
||||
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
setopt case_glob
|
||||
else
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
unsetopt case_glob
|
||||
fi
|
||||
|
||||
# Group matches and describe.
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*:matches' group 'yes'
|
||||
zstyle ':completion:*:options' description 'yes'
|
||||
zstyle ':completion:*:options' auto-description '%d'
|
||||
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
|
||||
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
|
||||
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
|
||||
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
|
||||
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
|
||||
zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
|
||||
zstyle ':completion:*' group-name ''
|
||||
zstyle ':completion:*' verbose yes
|
||||
|
||||
# Fuzzy match mistyped completions.
|
||||
zstyle ':completion:*' completer _complete _match _approximate
|
||||
zstyle ':completion:*:match:*' original only
|
||||
zstyle ':completion:*:approximate:*' max-errors 1 numeric
|
||||
|
||||
# Increase the number of errors based on the length of the typed word.
|
||||
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
|
||||
|
||||
# Don't complete unavailable commands.
|
||||
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))'
|
||||
|
||||
# Array completion element sorting.
|
||||
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
|
||||
|
||||
# Directories
|
||||
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
|
||||
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
|
||||
zstyle ':completion:*' squeeze-slashes true
|
||||
|
||||
# History
|
||||
zstyle ':completion:*:history-words' stop yes
|
||||
zstyle ':completion:*:history-words' remove-all-dups yes
|
||||
zstyle ':completion:*:history-words' list false
|
||||
zstyle ':completion:*:history-words' menu yes
|
||||
|
||||
# Environmental Variables
|
||||
zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-}
|
||||
|
||||
# Populate hostname completion.
|
||||
zstyle -e ':completion:*:hosts' hosts 'reply=(
|
||||
${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
|
||||
${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*}
|
||||
${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}}
|
||||
)'
|
||||
|
||||
# Don't complete uninteresting users...
|
||||
zstyle ':completion:*:*:*:users' ignored-patterns \
|
||||
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
|
||||
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
|
||||
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
|
||||
mailman mailnull mldonkey mysql nagios \
|
||||
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
|
||||
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
|
||||
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*'
|
||||
|
||||
# ... unless we really want to.
|
||||
zstyle '*' single-ignored show
|
||||
|
||||
# Ignore multiple entries.
|
||||
zstyle ':completion:*:(rm|kill|diff):*' ignore-line yes
|
||||
zstyle ':completion:*:rm:*' file-patterns '*:all-files'
|
||||
|
||||
# Kill
|
||||
zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm -w'
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01'
|
||||
zstyle ':completion:*:*:kill:*' menu yes select
|
||||
zstyle ':completion:*:*:kill:*' force-list always
|
||||
zstyle ':completion:*:*:kill:*' insert-ids single
|
||||
|
||||
# Man
|
||||
zstyle ':completion:*:manuals' separate-sections true
|
||||
zstyle ':completion:*:manuals.(^1*)' insert-sections true
|
||||
|
||||
# Media Players
|
||||
zstyle ':completion:*:*:mpg123:*' file-patterns '*.(mp3|MP3):mp3\ files *(-/):directories'
|
||||
zstyle ':completion:*:*:mpg321:*' file-patterns '*.(mp3|MP3):mp3\ files *(-/):directories'
|
||||
zstyle ':completion:*:*:ogg123:*' file-patterns '*.(ogg|OGG|flac):ogg\ files *(-/):directories'
|
||||
zstyle ':completion:*:*:mocp:*' file-patterns '*.(wav|WAV|mp3|MP3|ogg|OGG|flac):ogg\ files *(-/):directories'
|
||||
|
||||
# Mutt
|
||||
if [[ -f ~/.mutt/aliases ]]; then
|
||||
zstyle ':completion:*:*:mutt:*' menu yes select
|
||||
zstyle ':completion:*:mutt:*' users ${${${(f)"$(<~/.mutt/aliases)"}#alias[[:space:]]}%%[[:space:]]*}
|
||||
fi
|
||||
|
||||
# SSH/SCP/RSYNC
|
||||
zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
|
||||
zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr
|
||||
zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
|
||||
zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr
|
||||
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*.*' loopback localhost
|
||||
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^*.*' '*@*'
|
||||
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^<->.<->.<->.<->' '127.0.0.<->'
|
||||
|
@ -1,23 +0,0 @@
|
||||
setopt auto_cd # Auto cd to a directory without typing cd.
|
||||
setopt auto_pushd # Push the old directory onto the stack on cd.
|
||||
setopt pushd_ignore_dups # Don't store duplicates in the stack.
|
||||
setopt pushd_silent # Do not print the directory stack after pushd or popd.
|
||||
setopt pushd_to_home # Push to home directory when no argument is given.
|
||||
setopt pushd_minus # Use +/-n to specify a directory in the stack.
|
||||
setopt cdable_vars # Change directory to a path stored in a variable.
|
||||
setopt auto_name_dirs # Auto add variable-stored paths to ~ list.
|
||||
setopt multios # Write to multiple descriptors.
|
||||
setopt extended_glob # Use extended globbing syntax.
|
||||
unsetopt clobber # Don't overwrite existing files with > and >>.
|
||||
# Use >! and >>! to bypass.
|
||||
|
||||
alias 1='cd -'
|
||||
alias 2='cd +2'
|
||||
alias 3='cd +3'
|
||||
alias 4='cd +4'
|
||||
alias 5='cd +5'
|
||||
alias 6='cd +6'
|
||||
alias 7='cd +7'
|
||||
alias 8='cd +8'
|
||||
alias 9='cd +9'
|
||||
|
@ -1,101 +0,0 @@
|
||||
# Smart URLs
|
||||
autoload -Uz url-quote-magic
|
||||
zle -N self-insert url-quote-magic
|
||||
|
||||
# General
|
||||
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.
|
||||
|
||||
# PATH
|
||||
typeset -U path manpath cdpath fpath
|
||||
|
||||
path=(
|
||||
$HOME/.tilde/bin
|
||||
$HOME/.tilde/opt/bin
|
||||
/usr/local/bin
|
||||
/usr/local/sbin
|
||||
/usr/bin
|
||||
/bin
|
||||
/usr/sbin
|
||||
/sbin
|
||||
)
|
||||
|
||||
for path_file in /etc/paths.d/*; do
|
||||
path+=($(<$path_file))
|
||||
done
|
||||
|
||||
manpath=(
|
||||
$HOME/.tilde/share/man
|
||||
$HOME/.tilde/opt/share/man
|
||||
/usr/local/share/man
|
||||
/usr/share/man
|
||||
)
|
||||
|
||||
for path_file in /etc/manpaths.d/*; do
|
||||
manpath+=($(<$path_file))
|
||||
done
|
||||
|
||||
cdpath=(
|
||||
$HOME
|
||||
$HOME/Developer
|
||||
)
|
||||
|
||||
# Language
|
||||
export LANG="en_AU.UTF-8"
|
||||
export LC_ALL="$LANG"
|
||||
export LC_COLLATE="$LANG"
|
||||
export LC_CTYPE="$LANG"
|
||||
export LC_MESSAGES="$LANG"
|
||||
export LC_MONETARY="$LANG"
|
||||
export LC_NUMERIC="$LANG"
|
||||
export LC_TIME="$LANG"
|
||||
|
||||
# Editors
|
||||
export EDITOR="vim"
|
||||
export VISUAL="vim"
|
||||
export PAGER='less'
|
||||
|
||||
# Grep
|
||||
if check-bool "$COLOR"; then
|
||||
export GREP_COLOR='37;45'
|
||||
export GREP_OPTIONS='--color=auto'
|
||||
fi
|
||||
|
||||
# Browser (Default)
|
||||
if (( $+commands[xdg-open] )); then
|
||||
export BROWSER='xdg-open'
|
||||
fi
|
||||
|
||||
if (( $+commands[open] )); then
|
||||
export BROWSER='open'
|
||||
fi
|
||||
|
||||
# Less
|
||||
export LESSCHARSET="UTF-8"
|
||||
export LESSHISTFILE='-'
|
||||
export LESSEDIT='vim ?lm+%lm. %f'
|
||||
export LESS='-F -g -i -M -R -S -w -X -z-4'
|
||||
|
||||
if (( $+commands[lesspipe.sh] )); then
|
||||
export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-'
|
||||
fi
|
||||
|
||||
# Termcap
|
||||
if check-bool "$COLOR"; then
|
||||
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
|
||||
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
|
||||
export LESS_TERMCAP_me=$'\E[0m' # end mode
|
||||
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
|
||||
export LESS_TERMCAP_so=$'\E[00;47;30m' # begin standout-mode
|
||||
export LESS_TERMCAP_ue=$'\E[0m' # end underline
|
||||
export LESS_TERMCAP_us=$'\E[01;32m' # begin underline
|
||||
fi
|
||||
|
@ -1,50 +0,0 @@
|
||||
# Checks if a file can be autoloaded by trying to load it in a subshell.
|
||||
function autoloadable() {
|
||||
( unfunction $1 ; autoload -U +X $1 ) &> /dev/null
|
||||
}
|
||||
|
||||
# Checks boolean variable for "true" (case insensitive "1", "y", "yes", "t", "true", "o", and "on").
|
||||
function check-bool {
|
||||
[[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]]
|
||||
}
|
||||
|
||||
# Trap signals were generated with 'kill -l'.
|
||||
# DEBUG, EXIT, and ZERR are ZSH signals.
|
||||
TRAP_SIGNALS=(
|
||||
ABRT ALRM BUS CHLD CONT EMT FPE HUP ILL INFO INT IO KILL PIPE PROF QUIT
|
||||
SEGV STOP SYS TERM TRAP TSTP TTIN TTOU URG USR1 USR2 VTALRM WINCH XCPU XFSZ
|
||||
DEBUG EXIT ZERR
|
||||
)
|
||||
|
||||
# Adds a function to a list to be called when a trap is triggered.
|
||||
function add-zsh-trap {
|
||||
if (( $# < 2 )); then
|
||||
echo "Usage: $0 type function"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "$TRAP_SIGNALS[(r)$1]" ]]; then
|
||||
echo "$0: unknown signal: $1"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local trap_functions="TRAP${1}_FUNCTIONS"
|
||||
if (( ! ${(P)+trap_functions} )); then
|
||||
typeset -gaU "$trap_functions"
|
||||
fi
|
||||
eval "$trap_functions+="$2""
|
||||
|
||||
if (( ! $+functions[TRAP${1}] )); then
|
||||
eval "
|
||||
function TRAP${1}() {
|
||||
for trap_function in \"\$TRAP${1}_FUNCTIONS[@]\"; do
|
||||
if (( \$+functions[\$trap_function] )); then
|
||||
\"\$trap_function\" \"\$1\"
|
||||
fi
|
||||
done
|
||||
return \$(( 128 + \$1 ))
|
||||
}
|
||||
"
|
||||
fi
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
HISTFILE="$HOME/.zhistory"
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
|
||||
setopt bang_hist # Treat the '!' character specially during expansion.
|
||||
setopt extended_history # Write the history file in the ":start:elapsed;command" format.
|
||||
setopt append_history # Append to the history file, don't replace it.
|
||||
setopt inc_append_history # Write to the history file immediately, not when the shell exits.
|
||||
setopt share_history # Share history between all sessions.
|
||||
setopt hist_expire_dups_first # Expire duplicate entries first when trimming history.
|
||||
setopt hist_ignore_dups # Don't record an entry that was just recorded again.
|
||||
setopt hist_ignore_all_dups # Delete old recorded entry if new entry is a duplicate.
|
||||
setopt hist_find_no_dups # Do not display a line previously found.
|
||||
setopt hist_ignore_space # Don't record an entry starting with a space.
|
||||
setopt hist_save_no_dups # Don't write duplicate entries in the history file.
|
||||
setopt hist_reduce_blanks # Remove superfluous blanks before recording entry.
|
||||
setopt hist_verify # Don't execute immediately upon history expansion.
|
||||
setopt hist_beep # Beep when accessing nonexistent history.
|
||||
|
@ -1,12 +0,0 @@
|
||||
# Source function files (the order matters).
|
||||
source "${0:h}/helper.zsh"
|
||||
source "${0:h}/environment.zsh"
|
||||
source "${0:h}/terminal.zsh"
|
||||
source "${0:h}/keyboard.zsh"
|
||||
source "${0:h}/completion.zsh"
|
||||
source "${0:h}/history.zsh"
|
||||
source "${0:h}/directory.zsh"
|
||||
source "${0:h}/alias.zsh"
|
||||
source "${0:h}/spectrum.zsh"
|
||||
source "${0:h}/utility.zsh"
|
||||
|
@ -1,259 +0,0 @@
|
||||
# Beep on error in line editor.
|
||||
setopt beep
|
||||
|
||||
# Reset to default key bindings.
|
||||
bindkey -d
|
||||
|
||||
# Allow command line editing in an external editor.
|
||||
autoload -Uz edit-command-line
|
||||
zle -N edit-command-line
|
||||
|
||||
# Use human-friendly identifiers.
|
||||
typeset -g -A keys
|
||||
keys=(
|
||||
'Control' '\C-'
|
||||
'Escape' '\e'
|
||||
'Meta' '\M-'
|
||||
'F1' '^[OP'
|
||||
'F2' '^[OQ'
|
||||
'F3' '^[OR'
|
||||
'F4' '^[OS'
|
||||
'F5' '^[[15~'
|
||||
'F6' '^[[17~'
|
||||
'F7' '^[[18~'
|
||||
'F8' '^[[19~'
|
||||
'F9' '^[[20~'
|
||||
'F10' '^[[21~'
|
||||
'F11' '^[[23~'
|
||||
'F12' '^[[24~'
|
||||
'Backspace' '^?'
|
||||
'Insert' '^[[2~'
|
||||
'Home' '^[[H'
|
||||
'PageUp' '^[[5~'
|
||||
'Delete' '^[[3~'
|
||||
'End' '^[[F'
|
||||
'PageDown' '^[[6~'
|
||||
'Up' '^[[A'
|
||||
'Left' '^[[D'
|
||||
'Down' '^[[B'
|
||||
'Right' '^[[C'
|
||||
'Menu' '^[[29~'
|
||||
)
|
||||
|
||||
if [[ "$KEYMAP" == (emacs|) ]]; then
|
||||
# Use Emacs key bindings.
|
||||
bindkey -e
|
||||
|
||||
bindkey "${keys[Escape]}b" emacs-backward-word
|
||||
bindkey "${keys[Escape]}f" emacs-forward-word
|
||||
bindkey "${keys[Escape]}${keys[Left]}" emacs-backward-word
|
||||
bindkey "${keys[Escape]}${keys[Right]}" emacs-forward-word
|
||||
|
||||
# Kill to the beginning of the line.
|
||||
bindkey "${keys[Control]}u" backward-kill-line
|
||||
|
||||
# Kill to the beginning of the word.
|
||||
bindkey "${keys[Control]}w" backward-kill-word
|
||||
|
||||
# Undo/Redo
|
||||
bindkey "${keys[Control]}_" undo
|
||||
bindkey "${keys[Escape]}_" redo
|
||||
|
||||
# Search character.
|
||||
bindkey "${keys[Control]}]" vi-find-next-char
|
||||
bindkey "${keys[Escape]}${keys[Control]}]" vi-find-prev-char
|
||||
|
||||
# Edit command in an external editor.
|
||||
bindkey "${keys[Control]}x${keys[Control]}e" edit-command-line
|
||||
|
||||
# Expand .... to ../..
|
||||
if check-bool "$DOT_EXPANSION"; then
|
||||
bindkey "." expand-dot-to-parent-directory-path
|
||||
fi
|
||||
|
||||
# Bind to history substring search plugin if enabled;
|
||||
# otherwise, bind to built-in ZSH history search.
|
||||
if (( ${+widgets[history-incremental-pattern-search-backward]} )); then
|
||||
bindkey "${keys[Control]}r" history-incremental-pattern-search-backward
|
||||
bindkey "${keys[Control]}s" history-incremental-pattern-search-forward
|
||||
else
|
||||
bindkey "${keys[Control]}r" history-incremental-search-backward
|
||||
bindkey "${keys[Control]}s" history-incremental-search-forward
|
||||
fi
|
||||
elif [[ "$KEYMAP" == 'vi' ]]; then
|
||||
# Use vi key bindings.
|
||||
bindkey -v
|
||||
|
||||
# The default mode indicator.
|
||||
MODE_INDICATOR="%B%F{red}❮%f%b%F{red}❮❮%f"
|
||||
|
||||
# Restores RPROMPT when exiting vicmd.
|
||||
function vi-restore-rprompt() {
|
||||
if (( $+RPROMPT_CACHED )); then
|
||||
RPROMPT="$RPROMPT_CACHED"
|
||||
unset RPROMPT_CACHED
|
||||
zle reset-prompt
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
add-zsh-trap INT vi-restore-rprompt
|
||||
|
||||
# Displays the current vi mode (command).
|
||||
function zle-keymap-select() {
|
||||
if ! vi-restore-rprompt && [[ "$KEYMAP" == 'vicmd' ]]; then
|
||||
RPROMPT_CACHED="$RPROMPT"
|
||||
RPROMPT="$MODE_INDICATOR"
|
||||
zle reset-prompt
|
||||
fi
|
||||
}
|
||||
zle -N zle-keymap-select
|
||||
|
||||
# Resets the prompt after exiting edit-command-line.
|
||||
function zle-line-init() {
|
||||
vi-restore-rprompt
|
||||
}
|
||||
zle -N zle-line-init
|
||||
|
||||
# Resets the prompt after the line has been accepted.
|
||||
function zle-line-finish() {
|
||||
vi-restore-rprompt
|
||||
}
|
||||
zle -N zle-line-finish
|
||||
|
||||
# Edit command in an external editor.
|
||||
bindkey -M vicmd "v" edit-command-line
|
||||
|
||||
# Show cursor position.
|
||||
bindkey -M vicmd "ga" what-cursor-position
|
||||
|
||||
# Undo/Redo
|
||||
bindkey -M vicmd "u" undo
|
||||
bindkey -M vicmd "${keys[Control]}r" redo
|
||||
|
||||
# Expand .... to ../..
|
||||
if check-bool "$DOT_EXPANSION"; then
|
||||
bindkey -M viins "." expand-dot-to-parent-directory-path
|
||||
fi
|
||||
|
||||
# Switch to command mode.
|
||||
bindkey -M viins "jk" vi-cmd-mode
|
||||
bindkey -M viins "kj" vi-cmd-mode
|
||||
|
||||
# Emacs key bindings in insert mode.
|
||||
bindkey -M viins "${keys[Control]}a" beginning-of-line
|
||||
bindkey -M viins "${keys[Control]}b" backward-char
|
||||
bindkey -M viins "${keys[Escape]}b" emacs-backward-word
|
||||
bindkey -M viins "${keys[Control]}d" delete-char-or-list
|
||||
bindkey -M viins "${keys[Escape]}d" kill-word
|
||||
bindkey -M viins "${keys[Control]}e" end-of-line
|
||||
bindkey -M viins "${keys[Control]}f" forward-char
|
||||
bindkey -M viins "${keys[Escape]}f" emacs-forward-word
|
||||
bindkey -M viins "${keys[Control]}k" kill-line
|
||||
bindkey -M viins "${keys[Control]}u" backward-kill-line
|
||||
bindkey -M viins "${keys[Control]}w" backward-kill-word
|
||||
bindkey -M viins "${keys[Escape]}w" copy-region-as-kill
|
||||
bindkey -M viins "${keys[Escape]}h" run-help
|
||||
bindkey -M viins "${keys[Escape]}${keys[Left]}" emacs-backward-word
|
||||
bindkey -M viins "${keys[Escape]}${keys[Right]}" emacs-forward-word
|
||||
|
||||
# History
|
||||
bindkey -M vicmd "gg" beginning-of-history
|
||||
bindkey -M vicmd "G" end-of-history
|
||||
|
||||
# Bind to history substring search plugin if enabled;
|
||||
# otherwise, bind to built-in ZSH history search.
|
||||
if (( $+plugins[(er)history-substring-search] )); then
|
||||
bindkey -M vicmd "k" history-substring-search-up
|
||||
bindkey -M vicmd "j" history-substring-search-down
|
||||
else
|
||||
bindkey -M vicmd "k" up-line-or-history
|
||||
bindkey -M vicmd "j" down-line-or-history
|
||||
fi
|
||||
|
||||
if (( ${+widgets[history-incremental-pattern-search-backward]} )); then
|
||||
bindkey -M vicmd "?" history-incremental-pattern-search-backward
|
||||
bindkey -M vicmd "/" history-incremental-pattern-search-forward
|
||||
|
||||
# Emacs key bindings in insert mode.
|
||||
bindkey -M viins "${keys[Control]}r" history-incremental-pattern-search-backward
|
||||
bindkey -M viins "${keys[Control]}s" history-incremental-pattern-search-forward
|
||||
else
|
||||
bindkey -M vicmd "?" history-incremental-search-backward
|
||||
bindkey -M vicmd "/" history-incremental-search-forward
|
||||
|
||||
# Emacs key bindings in insert mode.
|
||||
bindkey -M viins "${keys[Control]}r" history-incremental-search-backward
|
||||
bindkey -M viins "${keys[Control]}s" history-incremental-search-forward
|
||||
fi
|
||||
else
|
||||
echo "oh-my-zsh: KEYMAP must be set 'emacs' or 'vi' but is set to '$KEYMAP'" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# The next key bindings are for both Emacs and Vi.
|
||||
bindkey "${keys[Home]}" beginning-of-line
|
||||
bindkey "${keys[End]}" end-of-line
|
||||
|
||||
bindkey "${keys[Insert]}" overwrite-mode
|
||||
bindkey "${keys[Delete]}" delete-char
|
||||
bindkey "${keys[Backspace]}" backward-delete-char
|
||||
|
||||
bindkey "${keys[Left]}" backward-char
|
||||
bindkey "${keys[Right]}" forward-char
|
||||
|
||||
# Expand history on space.
|
||||
bindkey ' ' magic-space
|
||||
|
||||
if (( $+plugins[(er)history-substring-search] )); then
|
||||
bindkey "${keys[Up]}" history-substring-search-up
|
||||
bindkey "${keys[Down]}" history-substring-search-down
|
||||
bindkey "${keys[Control]}p" history-substring-search-up
|
||||
bindkey "${keys[Control]}n" history-substring-search-down
|
||||
else
|
||||
bindkey "${keys[Up]}" up-line-or-history
|
||||
bindkey "${keys[Down]}" down-line-or-history
|
||||
bindkey "${keys[Control]}p" up-line-or-history
|
||||
bindkey "${keys[Control]}n" down-line-or-history
|
||||
fi
|
||||
|
||||
# Clear screen.
|
||||
bindkey "${keys[Control]}l" clear-screen
|
||||
|
||||
# Expand command name to full path.
|
||||
bindkey "${keys[Escape]}e" expand-cmd-path
|
||||
|
||||
# Duplicate the previous word.
|
||||
bindkey "${keys[Escape]}m" copy-prev-shell-word
|
||||
|
||||
# Bind Shift + Tab to go to the previous menu item.
|
||||
bindkey '^[[Z' reverse-menu-complete
|
||||
|
||||
# Complete in the middle of word.
|
||||
bindkey "${keys[Control]}i" expand-or-complete-prefix
|
||||
|
||||
# Convert .... to ../.. automatically.
|
||||
if check-bool "$DOT_EXPANSION"; then
|
||||
function expand-dot-to-parent-directory-path() {
|
||||
if [[ $LBUFFER = *.. ]]; then
|
||||
LBUFFER+=/..
|
||||
else
|
||||
LBUFFER+=.
|
||||
fi
|
||||
}
|
||||
zle -N expand-dot-to-parent-directory-path
|
||||
# Do not expand .... to ../.. during incremental search.
|
||||
bindkey -M isearch . self-insert 2>/dev/null
|
||||
fi
|
||||
|
||||
# Display an indicator when completing.
|
||||
if check-bool "$COMPLETION_INDICATOR"; then
|
||||
function expand-or-complete-prefix-with-indicator() {
|
||||
echo -n "\e[31m...\e[0m"
|
||||
zle expand-or-complete-prefix
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-prefix-with-indicator
|
||||
bindkey "${keys[Control]}i" expand-or-complete-prefix-with-indicator
|
||||
fi
|
||||
|
@ -1,61 +0,0 @@
|
||||
# A script to make using 256 colors in ZSH less painful.
|
||||
# P.C. Shyamshankar <sykora@lucentbeing.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
|
||||
typeset -Ag FX FG BG
|
||||
|
||||
FX=(
|
||||
none "\e[00m"
|
||||
normal "\e[22m"
|
||||
bold "\e[01m" no-bold "\e[22m"
|
||||
faint "\e[02m" no-faint "\e[22m"
|
||||
standout "\e[03m" no-standout "\e[23m"
|
||||
underline "\e[04m" no-underline "\e[24m"
|
||||
blink "\e[05m" no-blink "\e[25m"
|
||||
fast-blink "\e[06m" no-fast-blink "\e[25m"
|
||||
reverse "\e[07m" no-reverse "\e[27m"
|
||||
conceal "\e[08m" no-conceal "\e[28m"
|
||||
strikethrough "\e[09m" no-strikethrough "\e[29m"
|
||||
gothic "\e[20m" no-gothic "\e[22m"
|
||||
double-underline "\e[21m" no-double-underline "\e[22m"
|
||||
proportional "\e[26m" no-proportional "\e[50m"
|
||||
overline "\e[53m" no-overline "\e[55m"
|
||||
|
||||
no-border "\e[54m"
|
||||
border-rectangle "\e[51m" no-border-rectangle "\e[54m"
|
||||
border-circle "\e[52m" no-border-circle "\e[54m"
|
||||
|
||||
no-ideogram-marking "\e[65m"
|
||||
underline-or-right "\e[60m" no-underline-or-right "\e[65m"
|
||||
double-underline-or-right "\e[61m" no-double-underline-or-right "\e[65m"
|
||||
overline-or-left "\e[62m" no-overline-or-left "\e[65m"
|
||||
double-overline-or-left "\e[63m" no-double-overline-or-left "\e[65m"
|
||||
stress "\e[64m" no-stress "\e[65m"
|
||||
|
||||
font-default "\e[10m"
|
||||
font-first "\e[11m" no-font-first "\e[10m"
|
||||
font-second "\e[12m" no-font-second "\e[10m"
|
||||
font-third "\e[13m" no-font-third "\e[10m"
|
||||
font-fourth "\e[14m" no-font-fourth "\e[10m"
|
||||
font-fifth "\e[15m" no-font-fifth "\e[10m"
|
||||
font-sixth "\e[16m" no-font-sixth "\e[10m"
|
||||
font-seventh "\e[17m" no-font-seventh "\e[10m"
|
||||
font-eigth "\e[18m" no-font-eigth "\e[10m"
|
||||
font-ninth "\e[19m" no-font-ninth "\e[10m"
|
||||
)
|
||||
|
||||
FG[none]="$FX[none]"
|
||||
BG[none]="$FX[none]"
|
||||
colors=(black red green yellow blue magenta cyan white)
|
||||
for color in {0..255}; do
|
||||
if (( $color >= 0 )) && (( $color < $#colors )); then
|
||||
index=$(( $color + 1 ))
|
||||
FG[$colors[$index]]="\e[38;5;${color}m"
|
||||
BG[$colors[$index]]="\e[48;5;${color}m"
|
||||
fi
|
||||
|
||||
FG[$color]="\e[38;5;${color}m"
|
||||
BG[$color]="\e[48;5;${color}m"
|
||||
done
|
||||
unset colors color index
|
||||
|
@ -1,93 +0,0 @@
|
||||
# Dumb terminals lack support.
|
||||
if [[ "$TERM" == 'dumb' ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Set the GNU Screen window number.
|
||||
if [[ -n "$WINDOW" ]]; then
|
||||
export SCREEN_NO="%B${WINDOW}%b "
|
||||
else
|
||||
export SCREEN_NO=""
|
||||
fi
|
||||
|
||||
# Sets the GNU Screen title.
|
||||
function set-screen-title() {
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
printf "\ek%s\e\\" ${(V)argv}
|
||||
fi
|
||||
}
|
||||
|
||||
# Sets the terminal window title.
|
||||
function set-window-title() {
|
||||
if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then
|
||||
printf "\e]2;%s\a" ${(V)argv}
|
||||
fi
|
||||
}
|
||||
|
||||
# Sets the terminal tab title.
|
||||
function set-tab-title() {
|
||||
if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then
|
||||
printf "\e]1;%s\a" ${(V)argv}
|
||||
fi
|
||||
}
|
||||
|
||||
# Sets the tab and window titles with the command name.
|
||||
function set-title-by-command() {
|
||||
emulate -L zsh
|
||||
setopt localoptions extended_glob
|
||||
|
||||
# Get the command name that is under job control.
|
||||
if [[ "${1[(w)1]}" == (fg|%*)(\;|) ]]; then
|
||||
# Get the job name, and, if missing, set it to the default %+.
|
||||
local job_name="${${1[(wr)%*(\;|)]}:-%+}"
|
||||
|
||||
# Make a local copy for use in the subshell.
|
||||
local -A jobtexts_from_parent_shell
|
||||
jobtexts_from_parent_shell=(${(kv)jobtexts})
|
||||
|
||||
jobs $job_name 2>/dev/null > >(
|
||||
read index discarded
|
||||
# The index is already surrounded by brackets: [1].
|
||||
set-title-by-command "${(e):-\$jobtexts_from_parent_shell$index}"
|
||||
)
|
||||
else
|
||||
# Set the command name, or in the case of sudo or ssh, the next command.
|
||||
local cmd=${1[(wr)^(*=*|sudo|ssh|-*)]}
|
||||
|
||||
# Right-truncate the command name to 15 characters.
|
||||
if (( $#cmd > 15 )); then
|
||||
cmd="${cmd[1,15]}..."
|
||||
fi
|
||||
|
||||
for kind in window tab screen; do
|
||||
set-${kind}-title "$cmd"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Don't override precmd/preexec; append to hook array.
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
# Sets the tab and window titles before the prompt is displayed.
|
||||
function set-title-precmd {
|
||||
if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]] && check-bool "$AUTO_TITLE"; then
|
||||
set-window-title "${(%):-%~}"
|
||||
for kind in tab screen; do
|
||||
# Left-truncate the current working directory to 15 characters.
|
||||
set-${kind}-title "${(%):-%15<...<%~%<<}"
|
||||
done
|
||||
else
|
||||
# Set Apple Terminal current working directory.
|
||||
printf '\e]7;%s\a' "file://$HOST${PWD// /%20}"
|
||||
fi
|
||||
}
|
||||
add-zsh-hook precmd set-title-precmd
|
||||
|
||||
# Sets the tab and window titles before command execution.
|
||||
function set-title-preexec {
|
||||
if check-bool "$AUTO_TITLE"; then
|
||||
set-title-by-command "$2"
|
||||
fi
|
||||
}
|
||||
add-zsh-hook preexec set-title-preexec
|
||||
|
@ -1,84 +0,0 @@
|
||||
# Lists the ten most used commands.
|
||||
function history-stat() {
|
||||
history | awk '{print $2}' | sort | uniq -c | sort -n -r | head
|
||||
}
|
||||
|
||||
# Makes a directory and changes to it.
|
||||
function mkdcd() {
|
||||
mkdir -p "$@"
|
||||
cd "$argv[-1]"
|
||||
}
|
||||
compdef _mkdir mkdcd
|
||||
|
||||
# Changes to a directory and lists its contents.
|
||||
function cdll() {
|
||||
builtin cd "$@"
|
||||
ll
|
||||
}
|
||||
compdef _cd cdll
|
||||
|
||||
# Pushes an entry onto the directory stack and lists its contents.
|
||||
function pushdll() {
|
||||
builtin pushd "$@"
|
||||
ll
|
||||
}
|
||||
compdef _cd pushdll
|
||||
|
||||
# Pops an entry off the directory stack and lists its contents.
|
||||
function popdll() {
|
||||
builtin popd "$@"
|
||||
ll
|
||||
}
|
||||
compdef _cd popdll
|
||||
|
||||
# Gets ownership.
|
||||
function gown() {
|
||||
sudo chown -R "${USER}" "${1:-.}"
|
||||
}
|
||||
|
||||
# Reloads ~/.zshrc.
|
||||
function reload() {
|
||||
local zshrc="$HOME/.zshrc"
|
||||
if [[ -n "$1" ]]; then
|
||||
zshrc="$1"
|
||||
fi
|
||||
source "$zshrc"
|
||||
}
|
||||
|
||||
# Provides a simple calculator.
|
||||
function calc() {
|
||||
echo "scale=4; $@" | bc -l
|
||||
}
|
||||
|
||||
# Displays human readable disk usage statistics.
|
||||
function duh() {
|
||||
(( $# == 0 )) && set -- *
|
||||
if [[ "$OSTYPE" == linux* ]]; then
|
||||
du -khsc "$@" | sort -h -r
|
||||
else
|
||||
du -kcs "$@" | awk '{ printf "%9.1fM %s\n", $1 / 1024, $2 } ' | sort -n -r
|
||||
fi
|
||||
}
|
||||
compdef _du duh
|
||||
|
||||
# Prints columns 1 2 3 ... n.
|
||||
function slit() {
|
||||
awk "{ print $(for n; do echo -n "\$$n,"; done | sed 's/,$//') }"
|
||||
}
|
||||
|
||||
# Displays user owned process status.
|
||||
function pmine() {
|
||||
ps "$@" -u "$USER" -o pid,%cpu,%mem,command
|
||||
}
|
||||
compdef _ps pmine
|
||||
|
||||
# Finds files and executes a command on them.
|
||||
function findexec() {
|
||||
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
||||
}
|
||||
|
||||
# Serves a directory via HTTP.
|
||||
function httpserve() {
|
||||
python -m SimpleHTTPServer "$@"
|
||||
}
|
||||
|
Reference in New Issue
Block a user