Skip to content

Instantly share code, notes, and snippets.

@kennethreitz
Created April 14, 2011 19:46
Show Gist options
  • Save kennethreitz/920324 to your computer and use it in GitHub Desktop.
Save kennethreitz/920324 to your computer and use it in GitHub Desktop.
Server ZSH Setup (I use oh-my-zsh locally)
git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
echo "[%{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}]"
fi
}
# makes color constants available
autoload -U colors
colors
# enable colored output from ls, etc
export CLICOLOR=1
# expand functions in the prompt
setopt prompt_subst
# prompt
export PS1='$(git_prompt_info)[${SSH_CONNECTION+"%{$fg_bold[green]%}%n@%m:"}%{$fg_bold[blue]%}%~%{$reset_color%}] '
# autocompletion for ruby_test
# works with tu/tf aliases
_ruby_tests() {
if [[ -n $words[2] ]]; then
compadd `ruby_test -l ${words[2]}`
fi
}
compdef _ruby_tests ruby_test
# autocompletion for ruby_tu_rs
# works with su/sf aliases
_ruby_mixed_tests() {
if [[ -n $words[2] ]]; then
compadd `ruby_tu_rs -l ${words[2]}`
fi
}
compdef _ruby_mixed_tests ruby_tu_rs
_git_remote_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n $ref ]]; then
if (( CURRENT == 2 )); then
# first arg: operation
compadd create publish rename delete track
elif (( CURRENT == 3 )); then
# second arg: remote branch name
compadd `git branch -r | grep -v HEAD | sed "s/.*\///" | sed "s/ //g"`
elif (( CURRENT == 4 )); then
# third arg: remote name
compadd `git remote`
fi
else;
_files
fi
}
compdef _git_remote_branch grb
# autocompletion for schema
_rails_tables() {
if [[ -n $words[2] ]]; then
compadd `schema -l ${words[2]}`
fi
}
compdef _rails_tables schema
# completion
autoload -U compinit
compinit
# automatically enter directories without cd
setopt auto_cd
# use vim as an editor
export EDITOR=vim
# aliases
if [ -e "$HOME/.aliases" ]; then
source "$HOME/.aliases"
fi
# vi mode
bindkey -v
# use incremental search
bindkey ^R history-incremental-search-backward
# expand functions in the prompt
setopt prompt_subst
# prompt
export PS1='[${SSH_CONNECTION+"%n@%m:"}%~] '
# ignore duplicate history entries
setopt histignoredups
# keep more history
export HISTSIZE=2000
@kennethreitz
Copy link
Author

curl -O https://gist.github.com/raw/920324/.zlogin
curl -O https://gist.github.com/raw/920324/.zshrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment