Skip to content

Instantly share code, notes, and snippets.

@bamanzi
Created April 1, 2014 11:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bamanzi/9912135 to your computer and use it in GitHub Desktop.
Save bamanzi/9912135 to your computer and use it in GitHub Desktop.
zshrc
#** prompt
autoload -Uz promptinit
promptinit
prompt adam1
#** completion
# Use modern completion system
autoload -Uz compinit
compinit
zstyle ':completion:*' menu select=5
zstyle ':completion::approximate:' max-errors 1 numeric
# ZSH Gem #21: Completion of abbreviated filenames
# http://www.refining-linux.org/archives/56/ZSH-Gem-21-Completion-of-abbreviated-filenames/
#** history
setopt hist_ignore_space hist_ignore_alldups sharehistory
alias ls=" ls"
alias dir=" dir"
alias cd=" cd"
#** change directory
##useful?
#setopt auto_cd
#*** directory alias
#hash -d name=/path/to/real-folder
## then `cd ~name/subfolder` to use it
#*** auto pushd
# ZSH Gem #20: Changing directories the pro's way
# http://www.refining-linux.org/archives/55/ZSH-Gem-20-Changing-directories-the-pros-way/
setopt auto_pushd
# dirs -v
# cd +4
# cd -2
[ -f ~/bin/z.sh ] && source ~/bin/z.sh
function cdprjroot() {
cwd=$(pwd)
while true; do
for prjfile in .git .hg .projetile Gemfile setup.py; do
if [ -e $cwd/$prjfile ]; then
echo $cwd
pushd $cwd
break 2
fi
done
cwd=$(dirname $cwd)
done
}
#** asking for help
alias help=" run-help"
zman () {
PAGER="less -g -s '+/^ $1\b'" man zshall
}
#** misc
setopt no_nomatch
#*** Delete word stops at slash, like in bash.
#
# From http://www.zsh.org/mla/users/2005/msg01314.html and
# http://www.zsh.org/mla/users/2001/msg00870.html
backward-delete-to-slash () {
local WORDCHARS=${WORDCHARS//\//}
zle .backward-delete-word
}
zle -N backward-delete-to-slash
# '^[^?' means M-Backspace :P
bindkey '^[^?' backward-delete-to-slash
#** some keys
bindkey '\e[1~' beginning-of-line
bindkey '\e[H' beginning-of-line
bindkey '\eOH' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[H~' end-of-line
bindkey "^[OF" end-of-line
bindkey "^[[3~" delete-char
# M-F12
bindkey -s "^[^[[24~" "cdprjroot^M"
#** site-specific
export RPROMPT=`which ruby | sed 's#ruby/bin/ruby##'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment