Permalink
Browse files

alias and completion tweaks. rvm with version in prompt. git divergen…

…ce in prompt. my own theme.
  • Loading branch information...
Darrick Wiebe
Darrick Wiebe committed Feb 10, 2010
1 parent be66fe9 commit cae5705bd89c41757ea9c6767df4da96ef5f05ec
Showing with 81 additions and 39 deletions.
  1. +7 −21 lib/aliases.zsh
  2. +4 −1 lib/appearance.zsh
  3. +3 −1 lib/completion.zsh
  4. +1 −2 lib/directories.zsh
  5. +0 −5 lib/functions.zsh
  6. +27 −8 lib/git.zsh
  7. +1 −0 lib/rvm.zsh
  8. +1 −1 templates/zshrc.zsh-template
  9. +37 −0 themes/pangloss.zsh-theme
View
@@ -4,15 +4,16 @@
alias pu='pushd'
alias po='popd'
-alias ss='thin --stats "/thin/stats" start'
-alias sg='ruby script/generate'
-alias sd='ruby script/destroy'
-alias sp='ruby script/plugin'
-alias ssp='ruby script/spec'
-alias rdbm='rake db:migrate'
+# Rails
+alias s='thin --stats "/thin/stats" start'
+alias c='ruby script/console'
alias sc='ruby script/console'
+alias scprod='script/console production'
alias sd='ruby script/server --debugger'
alias devlog='tail -f log/development.log'
+alias migrate='rake db:migrate'
+alias unmigrate='rake db:rollback'
+alias cuc="cat tmp/cucumber | xargs cucumber --format progress --format rerun --out tmp/cucumber"
# Basic directory operations
alias .='pwd'
@@ -21,7 +22,6 @@ alias -- -='cd -'
# Super user
alias _='sudo'
-alias ss='sudo su -'
#alias g='grep -in'
@@ -34,20 +34,6 @@ alias l='ls -la'
alias ll='ls -alr'
alias sl=ls # often screw this up
-alias sgem='sudo gem'
-
# Find ruby file
alias rfind='find . -name *.rb | xargs grep -n'
alias afind='ack-grep -il'
-
-# Git and svn mix
-alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
-
-# TextMate
-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 &'
-
-# Editor Ruby file in TextMate
-alias mr='mate CHANGELOG app config db lib public script spec test'
View
@@ -30,9 +30,12 @@ ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of th
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_AHEAD=""
+ZSH_THEME_GIT_PROMPT_BEHIND=""
+ZSH_THEME_GIT_PROMPT_DIVERGED=""
# Setup the prompt with pretty colors
setopt prompt_subst
# Load the theme
-source "$ZSH/themes/$ZSH_THEME.zsh-theme"
+source "$ZSH/themes/$ZSH_THEME.zsh-theme"
View
@@ -30,16 +30,18 @@ unsetopt MENU_COMPLETE
# should this be in keybindings?
bindkey -M menuselect '^o' accept-and-infer-next-history
-zstyle ':completion:*:*:*:*:*' menu yes select
+zstyle ':completion:*:*:*:*:*' insert-unambiguous 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:*:*:*:*:processes' menu yes select
# Load known hosts file for auto-completion with ssh and scp commands
if [ -f ~/.ssh/known_hosts ]; then
zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts )
zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts`
+ zstyle ':completion:*:*:(ssh|scp):*:*' menu yes select
fi
# Complete on history
View
@@ -35,6 +35,5 @@ cd () {
}
alias md='mkdir -p'
-alias rd=rmdir
-alias d='dirs -v'
+alias d='dirs -v'
View
@@ -54,11 +54,6 @@ function take() {
cd $1
}
-function tm() {
- cd $1
- mate $1
-}
-
# To use: add a .lighthouse file into your directory with the URL to the
# individual project. For example:
# https://rails.lighthouseapp.com/projects/8994
View
@@ -1,7 +1,7 @@
# 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"
+ echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_divergence)$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
parse_git_dirty () {
@@ -12,6 +12,27 @@ parse_git_dirty () {
fi
}
+parse_git_divergence() {
+ git_status="$(git status 2> /dev/null)"
+ # would be more optimized to do status here...
+ #if [[ ! ${git_status}} =~ "working directory clean" ]]; then
+ #echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
+ #else
+ #echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
+ #fi
+ # add an else if or two here if you want to get more specific
+ if [[ ${git_status} =~ "# Your branch is (ahead|behind)" ]]; then
+ if [[ ${MATCH[-5,-1]} == "ahead" ]]; then
+ echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
+ else
+ echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
+ fi
+ elif [[ ${git_status} =~ "# Your branch and (.*) have diverged" ]]; then
+ echo "$ZSH_THEME_GIT_PROMPT_DIVERGED"
+ fi
+}
+
+
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
@@ -23,15 +44,13 @@ function current_branch() {
# Aliases
alias g='git'
-alias gst='git status'
-alias gl='git pull'
-alias gup='git fetch && git rebase'
-alias gp='git push'
-alias gd='git diff | mate'
+alias gs='git status'
+alias gd='git diff'
alias gdv='git diff -w "$@" | vim -R -'
alias gc='git commit -v'
alias gca='git commit -v -a'
-alias gb='git branch'
-alias gba='git branch -a'
+alias gb='git branch -a'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
+alias gdc='git diff --cached'
+alias gr="git remote -v"
View
@@ -0,0 +1 @@
+if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
@@ -3,7 +3,7 @@ export ZSH=$HOME/.oh-my-zsh
# Set to the name theme to load.
# Look in ~/.oh-my-zsh/themes/
-export ZSH_THEME="robbyrussell"
+export ZSH_THEME="pangloss"
# Set to this to use case-sensitive completion
# export CASE_SENSITIVE="true"
View
@@ -0,0 +1,37 @@
+function git_base_dir {
+ base_dir=$(git rev-parse --show-cdup 2>/dev/null) || return 1
+ if [ -n "$base_dir" ]; then
+ base_dir=`cd $base_dir; pwd`
+ else
+ base_dir=$PWD
+ fi
+ echo "$(basename "${base_dir}")"
+}
+
+function git_sub_dir() {
+ sub_dir=$(git rev-parse --show-prefix 2>/dev/null)
+ if [ "${sub_dir%/}" ]; then
+ echo "/${sub_dir%/}"
+ else
+ echo ""
+ fi
+}
+
+function current_subpath() {
+ if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == "true" ]]; then
+ echo $(git_base_dir)$(git_sub_dir)
+ else
+ echo $PWD
+ fi
+}
+
+local colon="%{$fg[blue]%}:%{$reset_color%}"
+PROMPT='%n$colon$RUBY_VERSION %{$fg[blue]%}➜%{$reset_color%} $(git_prompt_info)%{$fg_bold[white]%}$(current_subpath) $ %{$reset_color%}'
+
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}("
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} ⚡%{$fg[green]%}) %{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}) %{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[yellow]%} ↑%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[yellow]%} ↓%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIVERGED="%{$fg[yellow]%} ↕%{$reset_color%}"

0 comments on commit cae5705

Please sign in to comment.