mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 08:41:43 +00:00
Renamed lib/ to functions/ and renamed files inside of it.
This commit is contained in:
93
functions/alias.zsh
Normal file
93
functions/alias.zsh
Normal file
@ -0,0 +1,93 @@
|
||||
# The 'ls' family
|
||||
# ------------------------------------------------------------------------------
|
||||
if [[ "$DISABLE_COLOR" != 'true' ]]; then
|
||||
if (( ${+commands[dircolors]} )); then
|
||||
dircolors="${commands[dircolors]}"
|
||||
fi
|
||||
if (( ${+commands[gdircolors]} )); then
|
||||
dircolors="${commands[gdircolors]}"
|
||||
fi
|
||||
if [[ -x "$dircolors" ]] && [[ -e "$HOME/.dir_colors" ]]; then
|
||||
eval $("$dircolors" "$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 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 lasa.
|
||||
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 rm='nocorrect rm -i'
|
||||
alias cp='nocorrect cp -i'
|
||||
alias mv='nocorrect mv -i'
|
||||
alias ln='nocorrect ln -i'
|
||||
alias mkdir='nocorrect mkdir -p'
|
||||
alias du='du -kh'
|
||||
alias df='df -kh'
|
||||
alias pu='pushd'
|
||||
alias po='popd'
|
||||
alias _='sudo'
|
||||
alias e="$EDITOR"
|
||||
alias history='fc -l 1'
|
||||
alias get='curl -C - -O'
|
||||
alias afind='ack -il'
|
||||
alias type='type -a'
|
||||
alias ssh='ssh -X'
|
||||
alias print-path='echo -e ${PATH//:/\\n}'
|
||||
alias t="t --task-dir ~/.tasks --list todo.txt --delete-if-empty"
|
||||
|
||||
if [[ -x "${commands[htop]}" ]]; then
|
||||
alias top=htop
|
||||
else
|
||||
alias topm='top -o vsize'
|
||||
alias topc='top -o cpu'
|
||||
fi
|
||||
|
||||
if [[ "$DISABLE_COLOR" != 'true' ]]; then
|
||||
if [[ -x "${commands[colordiff]}" ]]; then
|
||||
alias diff='colordiff'
|
||||
fi
|
||||
|
||||
if [[ -x "${commands[colormake]}" ]]; then
|
||||
alias make='colormake'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Terminal Multiplexer
|
||||
# ------------------------------------------------------------------------------
|
||||
local screenrc tmuxconf
|
||||
if [[ "$TERM" == 'xterm-color' ]]; then
|
||||
if [[ -e "$HOME/.screenrc" ]]; then
|
||||
screenrc="-c '$HOME/.screenrc'"
|
||||
tmuxconf="-f '$HOME/.tmux.conf'"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$TERM" == 'xterm-256color' ]]; then
|
||||
if [[ -e "$HOME/.screenrc256" ]]; then
|
||||
screenrc="-c '$HOME/.screenrc256'"
|
||||
tmuxconf="-f '$HOME/.tmux256.conf'"
|
||||
fi
|
||||
fi
|
||||
|
||||
alias screen="screen $screenrc"
|
||||
alias sl="screen $screenrc -list"
|
||||
alias sr="screen $screenrc -a -A -U -D -R"
|
||||
alias S="screen $screenrc -U -S"
|
||||
|
||||
alias tmux="tmux $tmuxconf"
|
||||
alias tls="tmux list-sessions"
|
||||
|
23
functions/appearance.zsh
Normal file
23
functions/appearance.zsh
Normal file
@ -0,0 +1,23 @@
|
||||
# Load and run colors.
|
||||
autoload -U colors
|
||||
colors -i
|
||||
|
||||
# Set the GNU Screen window number.
|
||||
if [[ -n "$WINDOW" ]]; then
|
||||
SCREEN_NO="%B$WINDOW%b "
|
||||
else
|
||||
SCREEN_NO=""
|
||||
fi
|
||||
|
||||
# Set the default prompt theme.
|
||||
PS1="%n@%m:%~%# "
|
||||
|
||||
# Set the default Git prompt theme.
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix before the branch name.
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # Suffix after the branch name.
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Indicator to display if the branch is dirty.
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Indicator to display if the branch is clean.
|
||||
|
||||
# Enable parameter, arithmentic expansion and command substitution in prompt.
|
||||
setopt prompt_subst
|
||||
|
66
functions/completion.zsh
Normal file
66
functions/completion.zsh
Normal file
@ -0,0 +1,66 @@
|
||||
# Dumb terminals lack support.
|
||||
if [[ "$TERM" == 'dumb' ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
unsetopt menu_complete # Do not autoselect the first completion entry.
|
||||
unsetopt flow_control # Disable start/stop characters in shell editor.
|
||||
setopt auto_menu # Show completion menu on a succesive tab press.
|
||||
setopt complete_in_word # Complete from both ends of a word.
|
||||
setopt always_to_end # Move cursor to the end of a completed word.
|
||||
|
||||
WORDCHARS=''
|
||||
|
||||
# FIXME: complist is crashing ZSH on menu completion.
|
||||
# zmodload -i zsh/complist
|
||||
|
||||
## Case-insensitive (all), partial-word, and then substring completion.
|
||||
if [[ "$CASE_SENSITIVE" == "true" ]]; then
|
||||
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
unset CASE_SENSITIVE
|
||||
else
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
fi
|
||||
|
||||
zstyle ':completion:*' list-colors ''
|
||||
|
||||
# FIXME: It depends on complist which crashes ZSH on menu completion.
|
||||
# Should this be in key-bindings.zsh?
|
||||
# bindkey -M menuselect '^o' accept-and-infer-next-history
|
||||
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
|
||||
|
||||
# Disable named-directories autocompletion.
|
||||
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||
cdpath=(.)
|
||||
|
||||
# Use /etc/hosts and known_hosts for hostname completion.
|
||||
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
|
||||
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
|
||||
hosts=(
|
||||
"$_ssh_hosts[@]"
|
||||
"$_etc_hosts[@]"
|
||||
`hostname`
|
||||
localhost
|
||||
)
|
||||
zstyle ':completion:*:hosts' hosts $hosts
|
||||
|
||||
# Use caching to make completion for cammands such as dpkg and apt usable.
|
||||
zstyle ':completion::complete:*' use-cache 1
|
||||
zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
|
||||
|
||||
# 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
|
||||
|
11
functions/correction.zsh
Normal file
11
functions/correction.zsh
Normal file
@ -0,0 +1,11 @@
|
||||
setopt correct_all
|
||||
|
||||
alias man='nocorrect man'
|
||||
alias mv='nocorrect mv'
|
||||
alias mysql='nocorrect mysql'
|
||||
alias mkdir='nocorrect mkdir'
|
||||
alias gist='nocorrect gist'
|
||||
alias heroku='nocorrect heroku'
|
||||
alias ebuild='nocorrect ebuild'
|
||||
alias hpodder='nocorrect hpodder'
|
||||
|
38
functions/directory.zsh
Normal file
38
functions/directory.zsh
Normal file
@ -0,0 +1,38 @@
|
||||
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 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.
|
||||
|
||||
alias ..='cd ..'
|
||||
alias cd..='cd ..'
|
||||
alias cd...='cd ../..'
|
||||
alias cd....='cd ../../..'
|
||||
alias cd.....='cd ../../../..'
|
||||
alias cd/='cd /'
|
||||
|
||||
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'
|
||||
|
||||
cd () {
|
||||
if [[ "x$*" == "x..." ]]; then
|
||||
cd ../..
|
||||
elif [[ "x$*" == "x...." ]]; then
|
||||
cd ../../..
|
||||
elif [[ "x$*" == "x....." ]]; then
|
||||
cd ../../..
|
||||
elif [[ "x$*" == "x......" ]]; then
|
||||
cd ../../../..
|
||||
else
|
||||
builtin cd "$@"
|
||||
fi
|
||||
}
|
||||
|
12
functions/grep.zsh
Normal file
12
functions/grep.zsh
Normal file
@ -0,0 +1,12 @@
|
||||
if [[ "$DISABLE_COLOR" != 'true' ]]; then
|
||||
if [[ -z "$GREP_OPTIONS" ]]; then
|
||||
export GREP_OPTIONS='--color=auto'
|
||||
fi
|
||||
if [[ -z "$GREP_COLOR" ]]; then
|
||||
export GREP_COLOR='37;45'
|
||||
fi
|
||||
else
|
||||
export GREP_OPTIONS='--color=none'
|
||||
export GREP_COLOR=''
|
||||
fi
|
||||
|
14
functions/history.zsh
Normal file
14
functions/history.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
## Command history configuration
|
||||
HISTFILE="$HOME/.zsh_history"
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
|
||||
setopt hist_verify
|
||||
setopt hist_expire_dups_first
|
||||
setopt hist_ignore_space
|
||||
setopt hist_ignore_dups
|
||||
setopt share_history
|
||||
setopt append_history
|
||||
setopt extended_history
|
||||
setopt inc_append_history
|
||||
|
49
functions/keyboard.zsh
Normal file
49
functions/keyboard.zsh
Normal file
@ -0,0 +1,49 @@
|
||||
# TODO: Write a GNU Emacs key bindings file akin to the vi-mode plugin.
|
||||
|
||||
bindkey -e
|
||||
bindkey '\ew' kill-region
|
||||
bindkey -s '\el' "ls\n"
|
||||
bindkey -s '\e.' "..\n"
|
||||
bindkey '^r' history-incremental-search-backward
|
||||
bindkey "^[[5~" up-line-or-history
|
||||
bindkey "^[[6~" down-line-or-history
|
||||
|
||||
# Make key up/down move up/down or search history.
|
||||
bindkey '^[[A' up-line-or-search
|
||||
bindkey '^[[B' down-line-or-search
|
||||
|
||||
bindkey "^[[H" beginning-of-line
|
||||
bindkey "^[[1~" beginning-of-line
|
||||
bindkey "^[[F" end-of-line
|
||||
bindkey "^[[4~" end-of-line
|
||||
|
||||
# Do history expansion on space.
|
||||
bindkey ' ' magic-space
|
||||
|
||||
# File rename magick.
|
||||
bindkey "^[m" copy-prev-shell-word
|
||||
bindkey '^[[Z' reverse-menu-complete
|
||||
|
||||
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~.
|
||||
bindkey "^[[3~" delete-char
|
||||
bindkey "^[3;5~" delete-char
|
||||
bindkey "\e[3~" delete-char
|
||||
|
||||
# Consider GNU Emacs keybindings:
|
||||
|
||||
#bindkey -e # Emacs key bindings.
|
||||
#
|
||||
#bindkey '^[[A' up-line-or-search
|
||||
#bindkey '^[[B' down-line-or-search
|
||||
#bindkey '^[^[[C' emacs-forward-word
|
||||
#bindkey '^[^[[D' emacs-backward-word
|
||||
#
|
||||
#bindkey -s '^X^Z' '%-^M'
|
||||
#bindkey '^[e' expand-cmd-path
|
||||
#bindkey '^[^I' reverse-menu-complete
|
||||
#bindkey '^X^N' accept-and-infer-next-history
|
||||
#bindkey '^W' kill-region
|
||||
#bindkey '^I' complete-word
|
||||
## FIXME: A weird sequence that rxvt produces
|
||||
#bindkey -s '^[[Z' '\t'
|
||||
|
17
functions/mixed.zsh
Normal file
17
functions/mixed.zsh
Normal file
@ -0,0 +1,17 @@
|
||||
# Smart URLs
|
||||
autoload -U url-quote-magic
|
||||
zle -N self-insert url-quote-magic
|
||||
|
||||
# Jobs
|
||||
setopt long_list_jobs
|
||||
|
||||
# Pager
|
||||
if [[ -z "$PAGER" ]]; then
|
||||
export PAGER=less
|
||||
fi
|
||||
|
||||
# Localization
|
||||
if [[ -z "$LC_CTYPE" ]]; then
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
fi
|
||||
|
20
functions/spectrum.zsh
Normal file
20
functions/spectrum.zsh
Normal file
@ -0,0 +1,20 @@
|
||||
# A script to make using 256 colors in ZSH less painful.
|
||||
# P.C. Shyamshankar <sykora@lucentbeing.com>
|
||||
# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
|
||||
|
||||
typeset -Ag FX FG BG
|
||||
|
||||
FX=(
|
||||
reset "%{[00m%}"
|
||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
||||
)
|
||||
|
||||
for color in {000..255}; do
|
||||
FG[$color]="%{[38;5;${color}m%}"
|
||||
BG[$color]="%{[48;5;${color}m%}"
|
||||
done
|
||||
|
40
functions/terminal.zsh
Normal file
40
functions/terminal.zsh
Normal file
@ -0,0 +1,40 @@
|
||||
# Dumb terminals lack support.
|
||||
if [[ "$TERM" == 'dumb' ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Fully supports GNU Screen, iTerm, and most modern xterm and rxvt terminals.
|
||||
# Partially supports Mac OS X Terminal since it can't set window and tab separately.
|
||||
# Usage: title "tab title" "window title"
|
||||
function title {
|
||||
if [[ "$DISABLE_AUTO_TITLE" != 'true' ]]; then
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
# Set GNU Screen's hardstatus (usually truncated at 20 characters).
|
||||
print -Pn "\ek$1:q\e\\"
|
||||
elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]]; then
|
||||
# Set the window title.
|
||||
print -Pn "\e]2;$2:q\a"
|
||||
# Set the tab title (will override window title on a broken terminal).
|
||||
print -Pn "\e]1;$1:q\a"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 15 character, left-truncated current working directory.
|
||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<"
|
||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
|
||||
|
||||
# Set the tab and window titles before the prompt is displayed.
|
||||
function precmd {
|
||||
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
|
||||
}
|
||||
|
||||
# Set the tab and window titles before command execution.
|
||||
function preexec {
|
||||
emulate -L zsh
|
||||
setopt extended_glob
|
||||
# Command name only, or if this is sudo or ssh, the next command.
|
||||
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]}
|
||||
title "$CMD" "%100>...>$2%<<"
|
||||
}
|
||||
|
60
functions/utility.zsh
Normal file
60
functions/utility.zsh
Normal file
@ -0,0 +1,60 @@
|
||||
function history-stat() {
|
||||
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
|
||||
}
|
||||
|
||||
function mkdcd() {
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
}
|
||||
|
||||
function cdll() {
|
||||
if [[ -n "$1" ]]; then
|
||||
builtin cd "$1"
|
||||
ls -lFhA
|
||||
else
|
||||
ls -lFhA
|
||||
fi
|
||||
}
|
||||
|
||||
function pushdll() {
|
||||
if [[ -n "$1" ]]; then
|
||||
builtin pushd "$1"
|
||||
ls -lFhA
|
||||
else
|
||||
ls -lFhA
|
||||
fi
|
||||
}
|
||||
|
||||
function popdll() {
|
||||
builtin popd
|
||||
ls -lFhA
|
||||
}
|
||||
|
||||
function gown() {
|
||||
sudo chown -R "${USER}" "${1:-.}"
|
||||
}
|
||||
|
||||
function reload() {
|
||||
local zshrc="$HOME/.zshrc"
|
||||
if [[ -n "$1" ]]; then
|
||||
zshrc="$1"
|
||||
fi
|
||||
source "$zshrc"
|
||||
}
|
||||
|
||||
function calc() {
|
||||
echo "scale=4; $@" | bc -l
|
||||
}
|
||||
|
||||
function pmine() {
|
||||
ps "$@" -u "$USER" -o pid,%cpu,%mem,command
|
||||
}
|
||||
|
||||
function findexec() {
|
||||
find . -type f -iname "*${1:-}*" -exec "${2:-file}" {} \;
|
||||
}
|
||||
|
||||
function httpserve() {
|
||||
python -m SimpleHTTPServer "$@"
|
||||
}
|
||||
|
Reference in New Issue
Block a user