Browse code

Merge branch 'master' of http://github.com/robbyrussell/oh-my-zsh

Roman Kamyk authored on 22/02/2011 at 08:53:26
Showing 14 changed files
... ...
@@ -8,7 +8,7 @@ h2. Setup
8 8
 
9 9
 h3. The automatic installer... (do you trust me?)
10 10
 
11
-@wget http://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@
11
+@wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@
12 12
 
13 13
 h3. The manual way
14 14
 
... ...
@@ -38,7 +38,7 @@ h2. Usage
38 38
 * enable the plugins you want in your @~/.zshrc@ (take a look at @plugins/@ to see what's possible)
39 39
 ** example: @plugins=(git osx ruby)@
40 40
 * Theme support: Change the @ZSH_THEME@ environment variable in @~/.zshrc@.
41
-** Take a look at the "current themes":http://wiki.github.com/robbyrussell/oh-my-zsh/themes that come bundled with _Oh My Zsh_.
41
+** Take a look at the "current themes":https://wiki.github.com/robbyrussell/oh-my-zsh/themes that come bundled with _Oh My Zsh_.
42 42
 * much much more...  take a look at @lib/@ what _Oh My Zsh_ offers...
43 43
 
44 44
 h2. Useful
45 45
deleted file mode 100644
... ...
@@ -1,36 +0,0 @@
1
-# ls colors
2
-autoload colors; colors;
3
-export LSCOLORS="Gxfxcxdxbxegedabagacad"
4
-#export LS_COLORS
5
-
6
-# Enable ls colors
7
-if [ "$DISABLE_LS_COLORS" != "true" ]
8
-then
9
-  # Find the option for using colors in ls, depending on the version: Linux or BSD
10
-  ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
11
-fi
12
-
13
-#setopt no_beep
14
-setopt auto_cd
15
-setopt multios
16
-setopt cdablevarS
17
-
18
-if [[ x$WINDOW != x ]]
19
-then
20
-    SCREEN_NO="%B$WINDOW%b "
21
-else
22
-    SCREEN_NO=""
23
-fi
24
-
25
-# Apply theming defaults
26
-PS1="%n@%m:%~%# "
27
-
28
-# git theming default: Variables for theming the git info prompt
29
-ZSH_THEME_GIT_PROMPT_PREFIX="git:("         # Prefix at the very beginning of the prompt, before the branch name
30
-ZSH_THEME_GIT_PROMPT_SUFFIX=")"             # At the very end of the prompt
31
-ZSH_THEME_GIT_PROMPT_DIRTY="*"              # Text to display if the branch is dirty
32
-ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is clean
33
-
34
-# Setup the prompt with pretty colors
35
-setopt prompt_subst
36
-
... ...
@@ -1,26 +1,3 @@
1
-## fixme, i duplicated this in xterms - oops
2
-function title {
3
-  if [[ $TERM == "screen" ]]; then
4
-    # Use these two for GNU Screen:
5
-    print -nR $'\033k'$1$'\033'\\\
6
-
7
-    print -nR $'\033]0;'$2$'\a'
8
-  elif [[ ($TERM =~ "^xterm") ]] || [[ ($TERM == "rxvt") ]]; then
9
-    # Use this one instead for XTerms:
10
-    print -nR $'\033]0;'$*$'\a'
11
-  fi
12
-}
13
-
14
-function precmd {
15
-  title zsh "$PWD"
16
-}
17
-
18
-function preexec {
19
-  emulate -L zsh
20
-  local -a cmd; cmd=(${(z)1})
21
-  title $cmd[1]:t "$cmd[2,-1]"
22
-}
23
-
24 1
 function zsh_stats() {
25 2
   history | awk '{print $2}' | sort | uniq -c | sort -rn | head
26 3
 }
... ...
@@ -26,6 +26,10 @@ git_prompt_status() {
26 26
   fi
27 27
   if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
28 28
     STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
29
+  elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
30
+    STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
31
+  elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
32
+    STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
29 33
   fi
30 34
   if $(echo "$INDEX" | grep '^R  ' &> /dev/null); then
31 35
     STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
... ...
@@ -1,21 +1,26 @@
1
-case "$TERM" in
2
-  xterm*|rxvt*)
3
-    preexec () {
4
-      print -Pn "\e]0;%n@%m: $1\a"  # xterm
5
-    }
6
-    precmd () {
7
-      print -Pn "\e]0;%n@%m: %~\a"  # xterm
8
-    }
9
-    ;;
10
-  screen*)
11
-    preexec () {
12
-      local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]}
13
-      echo -ne "\ek$CMD\e\\"
14
-      print -Pn "\e]0;%n@%m: $1\a"  # xterm
15
-    }
16
-    precmd () {
17
-      echo -ne "\ekzsh\e\\"
18
-      print -Pn "\e]0;%n@%m: %~\a"  # xterm
19
-    }
20
-    ;;
21
-esac
22 1
\ No newline at end of file
2
+#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
3
+#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
4
+#Fully support screen, iterm, and probably most modern xterm and rxvt
5
+#Limited support for Apple Terminal (Terminal can't set window or tab separately)
6
+function title {
7
+  if [[ "$TERM" == "screen" ]]; then 
8
+    print -Pn "\ek$1\e\\" #set screen hardstatus, usually truncated at 20 chars
9
+  elif [[ ($TERM =~ "^xterm") ]] || [[ ($TERM == "rxvt") ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
10
+    print -Pn "\e]2;$2\a" #set window name
11
+    print -Pn "\e]1;$1\a" #set icon (=tab) name (will override window name on broken terminal)
12
+  fi
13
+}
14
+
15
+ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
16
+ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
17
+
18
+#Appears when you have the prompt
19
+function precmd {
20
+  title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
21
+}
22
+
23
+#Appears at the beginning of (and during) of command execution
24
+function preexec {
25
+  local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
26
+  title "$CMD" "%100>...>$2%<<"
27
+}
23 28
new file mode 100644
... ...
@@ -0,0 +1,36 @@
0
+# ls colors
1
+autoload colors; colors;
2
+export LSCOLORS="Gxfxcxdxbxegedabagacad"
3
+#export LS_COLORS
4
+
5
+# Enable ls colors
6
+if [ "$DISABLE_LS_COLORS" != "true" ]
7
+then
8
+  # Find the option for using colors in ls, depending on the version: Linux or BSD
9
+  ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
10
+fi
11
+
12
+#setopt no_beep
13
+setopt auto_cd
14
+setopt multios
15
+setopt cdablevarS
16
+
17
+if [[ x$WINDOW != x ]]
18
+then
19
+    SCREEN_NO="%B$WINDOW%b "
20
+else
21
+    SCREEN_NO=""
22
+fi
23
+
24
+# Apply theming defaults
25
+PS1="%n@%m:%~%# "
26
+
27
+# git theming default: Variables for theming the git info prompt
28
+ZSH_THEME_GIT_PROMPT_PREFIX="git:("         # Prefix at the very beginning of the prompt, before the branch name
29
+ZSH_THEME_GIT_PROMPT_SUFFIX=")"             # At the very end of the prompt
30
+ZSH_THEME_GIT_PROMPT_DIRTY="*"              # Text to display if the branch is dirty
31
+ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is clean
32
+
33
+# Setup the prompt with pretty colors
34
+setopt prompt_subst
35
+
0 36
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+alias be="bundle exec"
1
+alias bi="bundle install"
2
+alias bu="bundle update"
... ...
@@ -1,11 +1,57 @@
1
+function savepath() {
2
+  pwd > ~/.current_path~
3
+}
4
+
1 5
 function tab() {
2
-  osascript 2>/dev/null <<EOF
6
+savepath
7
+osascript >/dev/null <<EOF
8
+on do_submenu(app_name, menu_name, menu_item, submenu_item)
9
+    -- bring the target application to the front
10
+    tell application app_name
11
+      activate
12
+    end tell
3 13
     tell application "System Events"
4
-      tell process "Terminal" to keystroke "t" using command down
5
-    end
6
-    tell application "Terminal"
14
+      tell process app_name
15
+        tell menu bar 1
16
+          tell menu bar item menu_name
17
+            tell menu menu_name
18
+              tell menu item menu_item
19
+                tell menu menu_item
20
+                  click menu item submenu_item
21
+                end tell
22
+              end tell
23
+            end tell
24
+          end tell
25
+        end tell
26
+      end tell
27
+    end tell
28
+end do_submenu
29
+
30
+do_submenu("Terminal", "Shell", "New Tab", 1)
31
+EOF
32
+}
33
+
34
+function itab() {
35
+savepath
36
+osascript >/dev/null <<EOF
37
+on do_submenu(app_name, menu_name, menu_item)
38
+    -- bring the target application to the front
39
+    tell application app_name
7 40
       activate
8
-      do script with command "cd \"$PWD\"; $*" in window 1
9 41
     end tell
42
+    tell application "System Events"
43
+      tell process app_name
44
+        tell menu bar 1
45
+          tell menu bar item menu_name
46
+            tell menu menu_name
47
+              click menu item menu_item
48
+            end tell
49
+          end tell
50
+        end tell
51
+      end tell
52
+    end tell
53
+end do_submenu
54
+
55
+do_submenu("iTerm", "Shell", "New Tab")
10 56
 EOF
11
-}
12 57
\ No newline at end of file
58
+}
... ...
@@ -3,6 +3,8 @@ alias rg='ruby script/rails generate'
3 3
 alias rd='ruby script/rails destroy'
4 4
 alias rp='ruby script/rails plugin'
5 5
 alias rdbm='rake db:migrate db:test:clone'
6
+alias rdbmr='rake db:migrate && rake db:migrate:redo'
6 7
 alias rc='ruby script/rails console'
7
-alias rd='ruby script/rais server --debugger'
8
+alias rd='ruby script/rails server --debugger'
8 9
 alias devlog='tail -f log/development.log'
10
+
... ...
@@ -1,6 +1,63 @@
1
-PROMPT='%{$fg[blue]%}%B%20~%b%{$reset_color%}%{$(git_prompt_info)%} $ '
1
+PROMPT='%{$fg[blue]%}%n%{$reset_color%} on %{$fg[red]%}%M%{$reset_color%} in %{$fg[blue]%}%~%b%{$reset_color%}$(git_time_since_commit)$(git_prompt_info)
2
+$ '
2 3
 
3
-ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg[green]%}"
4
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%}"
4 5
 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
5
-ZSH_THEME_GIT_PROMPT_DIRTY="*%{$reset_color%}"
6 6
 
7
+# Text to display if the branch is dirty
8
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}" 
9
+
10
+# Text to display if the branch is clean
11
+ZSH_THEME_GIT_PROMPT_CLEAN="" 
12
+
13
+# Colors vary depending on time lapsed.
14
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
15
+ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
16
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
17
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
18
+
19
+# Determine the time since last commit. If branch is clean,
20
+# use a neutral color, otherwise colors will vary according to time.
21
+function git_time_since_commit() {
22
+    if git rev-parse --git-dir > /dev/null 2>&1; then
23
+        # Only proceed if there is actually a commit.
24
+        if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
25
+            # Get the last commit.
26
+            last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
27
+            now=`date +%s`
28
+            seconds_since_last_commit=$((now-last_commit))
29
+
30
+            # Totals
31
+            MINUTES=$((seconds_since_last_commit / 60))
32
+            HOURS=$((seconds_since_last_commit/3600))
33
+           
34
+            # Sub-hours and sub-minutes
35
+            DAYS=$((seconds_since_last_commit / 86400))
36
+            SUB_HOURS=$((HOURS % 24))
37
+            SUB_MINUTES=$((MINUTES % 60))
38
+            
39
+            if [[ -n $(git status -s 2> /dev/null) ]]; then
40
+                if [ "$MINUTES" -gt 30 ]; then
41
+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
42
+                elif [ "$MINUTES" -gt 10 ]; then
43
+                    COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
44
+                else
45
+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
46
+                fi
47
+            else
48
+                COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
49
+            fi
50
+
51
+            if [ "$HOURS" -gt 24 ]; then
52
+                echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
53
+            elif [ "$MINUTES" -gt 60 ]; then
54
+                echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
55
+            else
56
+                echo "($COLOR${MINUTES}m%{$reset_color%}|"
57
+            fi
58
+        else
59
+            COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
60
+            echo "($COLOR~|"
61
+        fi
62
+    fi
63
+}
7 64
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+PROMPT='%F{green}%2c%F{blue} [%f '
1
+RPROMPT='$(git_prompt_info) %F{blue}] %F{green}%D{%L:%M} %F{yellow}%D{%p}%f'
2
+
3
+ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}"
4
+ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
5
+ZSH_THEME_GIT_PROMPT_DIRTY=" %F{red}*%f"
6
+ZSH_THEME_GIT_PROMPT_CLEAN=""
0 7
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+#!/usr/bin/env zsh
1
+# ------------------------------------------------------------------------------
2
+# Prompt for the Zsh shell:
3
+#   * One line.
4
+#   * VCS info on the right prompt.
5
+#   * Only shows the path on the left prompt by default.
6
+#   * Crops the path to a defined length and only shows the path relative to
7
+#     the current VCS repository root.
8
+#   * Wears a different color wether the last command succeeded/failed.
9
+#   * Shows user@hostname if connected through SSH.
10
+#   * Shows if logged in as root or not.
11
+# ------------------------------------------------------------------------------
12
+
13
+# Customizable parameters.
14
+PROMPT_PATH_MAX_LENGTH=30
15
+PROMPT_DEFAULT_END=❯
16
+PROMPT_ROOT_END=❯❯❯
17
+PROMPT_SUCCESS_COLOR=$FG[071]
18
+PROMPT_FAILURE_COLOR=$FG[124]
19
+PROMPT_VCS_INFO_COLOR=$FG[242]
20
+
21
+# Set required options.
22
+setopt promptsubst
23
+
24
+# Load required modules.
25
+autoload -U add-zsh-hook
26
+autoload -Uz vcs_info
27
+
28
+# Add hook for calling vcs_info before each command.
29
+add-zsh-hook precmd vcs_info
30
+
31
+# Set vcs_info parameters.
32
+zstyle ':vcs_info:*' enable hg bzr git
33
+zstyle ':vcs_info:*:*' check-for-changes true # Can be slow on big repos.
34
+zstyle ':vcs_info:*:*' unstagedstr '!'
35
+zstyle ':vcs_info:*:*' stagedstr '+'
36
+zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)"
37
+zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c"
38
+zstyle ':vcs_info:*:*' nvcsformats "%~" ""
39
+
40
+# Define prompts.
41
+PROMPT="%(0?.%{$PROMPT_SUCCESS_COLOR%}.%{$PROMPT_FAILURE_COLOR%})${SSH_TTY:+[%n@%m]}%{$FX[bold]%}%$PROMPT_PATH_MAX_LENGTH<..<"'${vcs_info_msg_0_%%.}'"%<<%(!.$PROMPT_ROOT_END.$PROMPT_DEFAULT_END)%{$FX[no-bold]%}%{$FX[reset]%} "
42
+RPROMPT="%{$PROMPT_VCS_INFO_COLOR%}"'$vcs_info_msg_1_'"%{$FX[reset]%}"
0 43
new file mode 100644
... ...
@@ -0,0 +1,48 @@
0
+# ------------------------------------------------------------------------------
1
+#          FILE:  sorin.zsh-theme
2
+#   DESCRIPTION:  oh-my-zsh theme file.
3
+#        AUTHOR:  Sorin Ionescu (sorin.ionescu@gmail.com)
4
+#       VERSION:  1.0.2
5
+#    SCREENSHOT:  http://i.imgur.com/aipDQ.png
6
+# ------------------------------------------------------------------------------
7
+
8
+
9
+if [[ "$TERM" != "dumb" ]] && [[ "$DISABLE_LS_COLORS" != "true" ]]; then
10
+  MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}"
11
+  local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}"
12
+  
13
+  PROMPT='%{$fg[cyan]%}%c$(git_prompt_info) %(!.%{$fg_bold[red]%}#.%{$fg_bold[green]%}❯)%{$reset_color%} '
14
+
15
+  ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[blue]%}git%{$reset_color%}:%{$fg[red]%}"
16
+  ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
17
+  ZSH_THEME_GIT_PROMPT_DIRTY=""
18
+  ZSH_THEME_GIT_PROMPT_CLEAN=""
19
+
20
+  RPROMPT='${return_status}$(git_prompt_status)%{$reset_color%}'
21
+
22
+  ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
23
+  ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
24
+  ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
25
+  ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
26
+  ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
27
+  ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
28
+else 
29
+  MODE_INDICATOR="❮❮❮"
30
+  local return_status="%(?::⏎)"
31
+  
32
+  PROMPT='%c$(git_prompt_info) %(!.#.❯) '
33
+
34
+  ZSH_THEME_GIT_PROMPT_PREFIX=" git:"
35
+  ZSH_THEME_GIT_PROMPT_SUFFIX=""
36
+  ZSH_THEME_GIT_PROMPT_DIRTY=""
37
+  ZSH_THEME_GIT_PROMPT_CLEAN=""
38
+
39
+  RPROMPT='${return_status}$(git_prompt_status)'
40
+
41
+  ZSH_THEME_GIT_PROMPT_ADDED=" ✚"
42
+  ZSH_THEME_GIT_PROMPT_MODIFIED=" ✹"
43
+  ZSH_THEME_GIT_PROMPT_DELETED=" ✖"
44
+  ZSH_THEME_GIT_PROMPT_RENAMED=" ➜"
45
+  ZSH_THEME_GIT_PROMPT_UNMERGED=" ═"
46
+  ZSH_THEME_GIT_PROMPT_UNTRACKED=" ✭"
47
+fi
... ...
@@ -16,7 +16,7 @@ then
16 16
     _update_zsh_update && return 0;
17 17
   fi
18 18
 
19
-  epoch_diff=$((${_current_epoch} - $LAST_EPOCH))
19
+  epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
20 20
   if [ $epoch_diff -gt 6 ]
21 21
   then
22 22
     echo "[Oh My Zsh] Would you like to check for updates?"