Browse code

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

Claus Witt authored on 24/11/2010 at 10:06:05
Showing 6 changed files
... ...
@@ -34,9 +34,31 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm
34 34
 zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
35 35
 cdpath=(.)
36 36
 
37
+# use /etc/hosts and known_hosts for hostname completion
38
+[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
39
+[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
40
+hosts=(
41
+  "$_ssh_hosts[@]"
42
+  "$_etc_hosts[@]"
43
+  `hostname`
44
+  localhost
45
+)
46
+zstyle ':completion:*:hosts' hosts $hosts
47
+
48
+# Use caching so that commands like apt and dpkg complete are useable
49
+zstyle ':completion::complete:*' use-cache 1
50
+zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
51
+
52
+# Don't complete uninteresting users
53
+zstyle ':completion:*:*:*:users' ignored-patterns \
54
+        adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
55
+        dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
56
+        hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
57
+        mailman mailnull mldonkey mysql nagios \
58
+        named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
59
+        operator pcap postfix postgres privoxy pulse pvm quagga radvd \
60
+        rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
61
+
62
+# ... unless we really want to.
63
+zstyle '*' single-ignored show
37 64
 
38
-# Load known hosts file for auto-completion with ssh and scp commands
39
-if [ -f ~/.ssh/known_hosts ]; then
40
-  zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts )
41
-  zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts`
42
-fi
43 65
new file mode 100644
... ...
@@ -0,0 +1,5 @@
0
+# Uses the command-not-found package zsh support
1
+# as seen in http://www.porcheron.info/command-not-found-for-zsh/
2
+# this is installed in Ubuntu
3
+
4
+source /etc/zsh_command_not_found
... ...
@@ -4,7 +4,7 @@
4 4
 # Example usage: http://screencast.com/t/ZDgwNDUwNT
5 5
 open_lighthouse_ticket () {
6 6
   if [ ! -f .lighthouse-url ]; then
7
-    echo "There is no .lighthouse file in the current directory..."
7
+    echo "There is no .lighthouse-url file in the current directory..."
8 8
     return 0;
9 9
   else
10 10
     lighthouse_url=$(cat .lighthouse-url);
... ...
@@ -13,4 +13,4 @@ open_lighthouse_ticket () {
13 13
   fi
14 14
 }
15 15
 
16
-alias lho='open_lighthouse_ticket'
17 16
\ No newline at end of file
17
+alias lho='open_lighthouse_ticket'
18 18
new file mode 100644
... ...
@@ -0,0 +1,104 @@
0
+#compdef vagrant 
1
+#autoload
2
+
3
+# vagrant zsh completion
4
+
5
+local -a _1st_arguments
6
+_1st_arguments=(
7
+    'box:Box commands'
8
+    'destroy:Destroys the vagrant environment'
9
+    'halt:Halts the currently running vagrant environment'
10
+    'help:[TASK] Describe available tasks or one specific task'
11
+    'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
12
+    'package:Packages a vagrant environment for distribution'
13
+    'provision:Run the provisioner'
14
+    'reload:Reload the vagrant environment'
15
+    'resume:Resumes a suspend vagrant environment'
16
+    'ssh:SSH into the currently running environment'
17
+    'ssh_config:outputs .ssh/config valid syntax for connecting to this environment via ssh.'
18
+    'status:Shows the status of the current Vagrant environment.'
19
+    'suspend:Suspends the currently running vagrant environment'
20
+    'up:Creates the vagrant environment'
21
+    'version:Prints the Vagrant version information'
22
+)
23
+
24
+local -a _box_arguments
25
+_box_arguments=(
26
+    'add:NAME URI Add a box to the system'
27
+    'help:COMMAND Describe subcommands or one specific subcommand'
28
+    'list:Lists all installed boxes'
29
+    'remove:NAME Remove a box from the system'
30
+    'repackage:NAME Repackage an installed box into a `.box` file.'
31
+)
32
+
33
+__task_list ()
34
+{
35
+    local expl
36
+    declare -a tasks
37
+
38
+    tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version)
39
+
40
+    _wanted tasks expl 'help' compadd $tasks
41
+}
42
+
43
+__box_list ()
44
+{
45
+    _wanted application expl 'command' compadd $(command ls -1 $HOME/.vagrant/boxes 2>/dev/null| sed -e 's/ /\\ /g')
46
+}
47
+
48
+__vagrant-box ()
49
+{
50
+    local curcontext="$curcontext" state line
51
+    typeset -A opt_args
52
+
53
+    _arguments -C \
54
+        ':command:->command' \
55
+        '*::options:->options'
56
+
57
+   case $state in
58
+       (command)
59
+           _describe -t commands "gem subcommand" _box_arguments
60
+           return
61
+       ;;
62
+
63
+       (options)
64
+           case $line[1] in
65
+               (repackage|remove)
66
+                   _arguments ':feature:__box_list' 
67
+               ;;
68
+           esac
69
+       ;;
70
+    esac
71
+}
72
+
73
+
74
+
75
+
76
+local expl
77
+local -a boxes installed_boxes
78
+
79
+local curcontext="$curcontext" state line
80
+typeset -A opt_args
81
+
82
+_arguments -C \
83
+    ':command:->command' \
84
+    '*::options:->options'
85
+
86
+case $state in
87
+  (command)
88
+      _describe -t commands "gem subcommand" _1st_arguments
89
+      return
90
+  ;;
91
+
92
+  (options)
93
+    case $line[1] in
94
+      (help)
95
+         _arguments ':feature:__task_list' 
96
+      ;;
97
+
98
+      (box)
99
+          __vagrant-box
100
+      ;;
101
+    esac
102
+  ;;
103
+esac
0 104
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+fpath=($ZSH/plugins/vagrant $fpath)
1
+autoload -U compinit
2
+compinit -i
0 3
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
1
+local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
2
+
3
+local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
4
+local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
5
+local rvm_ruby='%{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v g)›%{$reset_color%}'
6
+local git_branch='$(git_prompt_info)%{$reset_color%}'
7
+
8
+PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
9
+╰─%B$%b "
10
+RPS1="${return_code}"
11
+
12
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
13
+ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"