mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 09:51:41 +00:00
Moving all zsh config options into a lib/ subdirectory to make way for some upcoming changes to directory structure and configuration options
This commit is contained in:
43
lib/aliases.zsh
Normal file
43
lib/aliases.zsh
Normal file
@ -0,0 +1,43 @@
|
||||
alias pu='pushd'
|
||||
alias po='popd'
|
||||
|
||||
alias sc='ruby script/console'
|
||||
alias sd='ruby script/server --debugger'
|
||||
alias ss='thin --stats "/thin/stats" start'
|
||||
|
||||
alias mr='mate CHANGELOG app config db lib public script spec test'
|
||||
alias .='pwd'
|
||||
alias ...='cd ../..'
|
||||
|
||||
alias _='sudo'
|
||||
|
||||
#alias g='grep -in'
|
||||
|
||||
alias g='git'
|
||||
alias gst='git status'
|
||||
alias gl='git pull'
|
||||
alias gp='git push'
|
||||
alias gd='git diff | mate'
|
||||
alias gc='git commit -v'
|
||||
alias gca='git commit -v -a'
|
||||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
|
||||
alias history='fc -l 1'
|
||||
|
||||
alias ls='ls -F'
|
||||
alias ll='ls -al'
|
||||
|
||||
alias sgem='sudo gem'
|
||||
|
||||
alias rfind='find . -name *.rb | xargs grep -n'
|
||||
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
|
||||
alias et='mate . &'
|
||||
alias ett='mate app config lib db public spec test Rakefile Capfile Todo &'
|
||||
alias etp='mate app config lib db public spec test vendor/plugins vendor/gems Rakefile Capfile Todo &'
|
||||
alias etts='mate app config lib db public script spec test vendor/plugins vendor/gems Rakefile Capfile Todo &'
|
||||
|
||||
|
||||
|
4
lib/colors.zsh
Normal file
4
lib/colors.zsh
Normal file
@ -0,0 +1,4 @@
|
||||
autoload colors; colors;
|
||||
|
||||
unset LSCOLORS
|
||||
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
|
30
lib/completion.zsh
Normal file
30
lib/completion.zsh
Normal file
@ -0,0 +1,30 @@
|
||||
setopt noautomenu
|
||||
setopt COMPLETE_IN_WORD
|
||||
setopt ALWAYS_TO_END
|
||||
|
||||
unsetopt flowcontrol
|
||||
|
||||
WORDCHARS=''
|
||||
|
||||
autoload -U compinit
|
||||
compinit
|
||||
|
||||
zmodload -i zsh/complist
|
||||
|
||||
## case-insensitive (all),partial-word and then substring completion
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
|
||||
zstyle ':completion:*' list-colors ''
|
||||
zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts )
|
||||
|
||||
unsetopt MENU_COMPLETE
|
||||
setopt AUTO_MENU
|
||||
|
||||
bindkey -M menuselect '^o' accept-and-infer-next-history
|
||||
|
||||
zstyle ':completion:*:*:*:*:*' menu yes select
|
||||
# zstyle ':completion:*:*:*:*:processes' force-list always
|
||||
|
||||
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"
|
||||
zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts`
|
59
lib/functions.zsh
Normal file
59
lib/functions.zsh
Normal file
@ -0,0 +1,59 @@
|
||||
function title {
|
||||
if [[ $TERM == "screen" ]]; then
|
||||
# Use these two for GNU Screen:
|
||||
print -nR $'\033k'$1$'\033'\\\
|
||||
|
||||
print -nR $'\033]0;'$2$'\a'
|
||||
elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then
|
||||
# Use this one instead for XTerms:
|
||||
print -nR $'\033]0;'$*$'\a'
|
||||
fi
|
||||
}
|
||||
|
||||
function precmd {
|
||||
title zsh "$PWD"
|
||||
}
|
||||
|
||||
function preexec {
|
||||
emulate -L zsh
|
||||
local -a cmd; cmd=(${(z)1})
|
||||
title $cmd[1]:t "$cmd[2,-1]"
|
||||
}
|
||||
|
||||
function remote_console() {
|
||||
/usr/bin/env ssh $1 "( cd $2 && ruby script/console production )"
|
||||
}
|
||||
|
||||
function zsh_stats() {
|
||||
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
|
||||
}
|
||||
|
||||
function uninstall_oh_my_zsh() {
|
||||
/bin/sh $ZSH/tools/uninstall.sh
|
||||
}
|
||||
|
||||
function upgrade_oh_my_zsh() {
|
||||
/bin/sh $ZSH/tools/upgrade.sh
|
||||
}
|
||||
|
||||
function tab() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
end
|
||||
tell application "Terminal"
|
||||
activate
|
||||
do script with command "cd $PWD; $*" in window 1
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
function take() {
|
||||
mkdir -p $1
|
||||
cd $1
|
||||
}
|
||||
|
||||
function tm() {
|
||||
cd $1
|
||||
mate $1
|
||||
}
|
25
lib/git.zsh
Normal file
25
lib/git.zsh
Normal file
@ -0,0 +1,25 @@
|
||||
# Varables for themeing the git info prompt:
|
||||
# ZSH_THEME_GIT_PROMPT_PREFIX - Prefix at the very beginning of the prompt, before the branch name
|
||||
# ZSH_THEME_GIT_PROMPT_SUFFIX - At the very end of the prompt
|
||||
# ZSH_THEME_GIT_PROMPT_DIRTY - Text to display if the branch is dirty
|
||||
# ZSH_THEME_GIT_PROMPT_CLEAN - Text to display if the branch is clean
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:("
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="*"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
# get the name of the branch we are on
|
||||
function git_prompt_info() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
}
|
||||
|
||||
parse_git_dirty () {
|
||||
if [[ $(git status | tail -n1) != "nothing to commit (working directory clean)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
6
lib/grep.zsh
Normal file
6
lib/grep.zsh
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
# Color grep results
|
||||
# Examples: http://rubyurl.com/ZXv
|
||||
#
|
||||
export GREP_OPTIONS='--color=auto'
|
||||
export GREP_COLOR='1;32'
|
15
lib/history.zsh
Normal file
15
lib/history.zsh
Normal file
@ -0,0 +1,15 @@
|
||||
# History stuff.
|
||||
setopt HIST_VERIFY
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt SHARE_HISTORY
|
||||
setopt EXTENDED_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
|
||||
## Command history configuration
|
||||
#
|
||||
HISTFILE=$ZSH/log/.zsh_history
|
||||
HISTSIZE=2500
|
||||
SAVEHIST=2500
|
||||
setopt hist_ignore_dups # ignore duplication command history list
|
||||
setopt share_history # share command history data
|
||||
|
14
lib/key-bindings.zsh
Normal file
14
lib/key-bindings.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
# TODO: Explain what some of this does..
|
||||
autoload -U compinit
|
||||
compinit
|
||||
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
|
||||
bindkey "^[[H" beginning-of-line
|
||||
bindkey "^[[1~" beginning-of-line
|
||||
bindkey "^[[F" end-of-line
|
||||
bindkey "^[[4~" end-of-line
|
||||
bindkey ' ' magic-space # also do history expansion on space
|
32
lib/prompt.zsh
Normal file
32
lib/prompt.zsh
Normal file
@ -0,0 +1,32 @@
|
||||
export PAGER=less
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
|
||||
bindkey -e
|
||||
|
||||
# Directory stuff.
|
||||
setopt AUTO_NAME_DIRS
|
||||
|
||||
# Speed stuff.
|
||||
|
||||
#setopt NO_BEEP
|
||||
setopt AUTO_CD
|
||||
setopt MULTIOS
|
||||
setopt CDABLEVARS
|
||||
|
||||
bindkey -e
|
||||
|
||||
if [[ x$WINDOW != x ]]
|
||||
then
|
||||
SCREEN_NO="%B$WINDOW%b "
|
||||
else
|
||||
SCREEN_NO=""
|
||||
fi
|
||||
|
||||
PS1="%n@%m:%~%# "
|
||||
|
||||
# Setup the prompt with pretty colors
|
||||
setopt prompt_subst
|
||||
|
||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
42
lib/rake_completion.zsh
Normal file
42
lib/rake_completion.zsh
Normal file
@ -0,0 +1,42 @@
|
||||
_rake_does_task_list_need_generating () {
|
||||
if [ ! -f .rake_tasks~ ]; then return 0;
|
||||
else
|
||||
accurate=$(stat -f%m .rake_tasks~)
|
||||
changed=$(stat -f%m Rakefile)
|
||||
return $(expr $accurate '>=' $changed)
|
||||
fi
|
||||
}
|
||||
|
||||
_rake () {
|
||||
if [ -f Rakefile ]; then
|
||||
if _rake_does_task_list_need_generating; then
|
||||
echo "\nGenerating .rake_tasks~..." > /dev/stderr
|
||||
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
|
||||
fi
|
||||
compadd `cat .rake_tasks~`
|
||||
fi
|
||||
}
|
||||
|
||||
compctl -K _rake rake
|
||||
|
||||
function _cap_does_task_list_need_generating () {
|
||||
if [ ! -f .cap_tasks~ ]; then return 0;
|
||||
else
|
||||
accurate=$(stat -f%m .cap_tasks~)
|
||||
changed=$(stat -f%m config/deploy.rb)
|
||||
return $(expr $accurate '>=' $changed)
|
||||
fi
|
||||
}
|
||||
|
||||
function _cap () {
|
||||
if [ -f config/deploy.rb ]; then
|
||||
if _cap_does_task_list_need_generating; then
|
||||
echo "\nGenerating .cap_tasks~..." > /dev/stderr
|
||||
cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D'
|
||||
> .cap_tasks~
|
||||
fi
|
||||
compadd `cat .cap_tasks~`
|
||||
fi
|
||||
}
|
||||
|
||||
compctl -K _cap cap
|
Reference in New Issue
Block a user