zsh_dots 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. data/.gitignore +25 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +47 -0
  4. data/Gemfile +7 -0
  5. data/Gemfile.lock +38 -0
  6. data/README.md +115 -0
  7. data/Rakefile +9 -0
  8. data/bin/dots +7 -0
  9. data/bin/elocal_nightly.sh +12 -0
  10. data/bin/gbrt +42 -0
  11. data/bin/git_cwd_info +40 -0
  12. data/bin/lein +229 -0
  13. data/bin/reattach-to-user-namespace +0 -0
  14. data/bin/ssh-copy-id +54 -0
  15. data/bin/stock +83 -0
  16. data/config/.dot_file +1 -0
  17. data/config/aws +0 -0
  18. data/config/example.aws.zsh +13 -0
  19. data/config/gemrc +9 -0
  20. data/config/gitconfig +46 -0
  21. data/config/railsrc +2 -0
  22. data/config/rspec +2 -0
  23. data/config/rvmrc +1 -0
  24. data/config/screenrc +1 -0
  25. data/config/tmux.conf +6 -0
  26. data/config/zlogin +1 -0
  27. data/config/zshenv +59 -0
  28. data/config/zshrc +8 -0
  29. data/etc/mandlebrot.c +59 -0
  30. data/etc/rails/composer.yml +30 -0
  31. data/etc/rails/ember_template.rb +60 -0
  32. data/etc/rails/recipes/haml_views.rb +20 -0
  33. data/etc/rails/recipes/html5.rb +84 -0
  34. data/etc/rails/recipes/readme_markdown.rb +87 -0
  35. data/etc/rails/template.rb +1419 -0
  36. data/lib/dots/aliases.zsh +40 -0
  37. data/lib/dots/directories.zsh +28 -0
  38. data/lib/dots/functions.zsh +41 -0
  39. data/lib/dots/plugins.zsh +18 -0
  40. data/lib/dots.sh +11 -0
  41. data/lib/plugins/aws/aws.plugin.zsh +20 -0
  42. data/lib/plugins/bundler/_bundler +82 -0
  43. data/lib/plugins/bundler/bundler.plugin.zsh +7 -0
  44. data/lib/plugins/git/git.plugin.zsh +126 -0
  45. data/lib/plugins/git-flow/git-flow.plugin.zsh +340 -0
  46. data/lib/plugins/knife/_knife +183 -0
  47. data/lib/plugins/knife/knife.plugin.zsh +1 -0
  48. data/lib/plugins/macvim/macvim.plugin.zsh +13 -0
  49. data/lib/plugins/osx/_man-preview +5 -0
  50. data/lib/plugins/osx/osx.plugin.zsh +101 -0
  51. data/lib/plugins/rails3/rails3.plugin.zsh +75 -0
  52. data/lib/plugins/rake/rake.plugin.zsh +6 -0
  53. data/lib/plugins/ruby/ruby.plugin.zsh +58 -0
  54. data/lib/ruby/dots/command.rb +58 -0
  55. data/lib/ruby/dots/dot_file.rb +73 -0
  56. data/lib/ruby/dots/version.rb +3 -0
  57. data/lib/ruby/dots.rb +9 -0
  58. data/lib/tasks/db.rake +55 -0
  59. data/lib/tasks/dots.rake +32 -0
  60. data/spec/integration/command_spec.rb +34 -0
  61. data/spec/models/dot_file_spec.rb +45 -0
  62. data/spec/spec_helper.rb +6 -0
  63. data/vendor/antigen.zsh +251 -0
  64. data/vendor/oh-my-zsh/check_for_upgrade.sh +45 -0
  65. data/vendor/oh-my-zsh/install.sh +43 -0
  66. data/vendor/oh-my-zsh/require_tool.sh +161 -0
  67. data/vendor/oh-my-zsh/uninstall.sh +20 -0
  68. data/vendor/oh-my-zsh/upgrade.sh +6 -0
  69. data/zsh_dots.gemspec +28 -0
  70. metadata +163 -0
@@ -0,0 +1,340 @@
1
+ #!zsh
2
+ #
3
+ # Installation
4
+ # ------------
5
+ #
6
+ # To achieve git-flow completion nirvana:
7
+ #
8
+ # 0. Update your zsh's git-completionti module to the newest verion.
9
+ # From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD
10
+ #
11
+ # 1. Install this file. Either:
12
+ #
13
+ # a. Place it in your .zshrc:
14
+ #
15
+ # b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in
16
+ # your .zshrc:
17
+ #
18
+ # source ~/.git-flow-completion.zsh
19
+ #
20
+ # c. Or, use this file as a oh-my-zsh plugin.
21
+ #
22
+
23
+ _git-flow ()
24
+ {
25
+ local curcontext="$curcontext" state line
26
+ typeset -A opt_args
27
+
28
+ _arguments -C \
29
+ ':command:->command' \
30
+ '*::options:->options'
31
+
32
+ case $state in
33
+ (command)
34
+
35
+ local -a subcommands
36
+ subcommands=(
37
+ 'init:Initialize a new git repo with support for the branching model.'
38
+ 'feature:Manage your feature branches.'
39
+ 'release:Manage your release branches.'
40
+ 'hotfix:Manage your hotfix branches.'
41
+ 'support:Manage your support branches.'
42
+ 'version:Shows version information.'
43
+ )
44
+ _describe -t commands 'git flow' subcommands
45
+ ;;
46
+
47
+ (options)
48
+ case $line[1] in
49
+
50
+ (init)
51
+ _arguments \
52
+ -f'[Force setting of gitflow branches, even if already configured]'
53
+ ;;
54
+
55
+ (version)
56
+ ;;
57
+
58
+ (hotfix)
59
+ __git-flow-hotfix
60
+ ;;
61
+
62
+ (release)
63
+ __git-flow-release
64
+ ;;
65
+
66
+ (feature)
67
+ __git-flow-feature
68
+ ;;
69
+ esac
70
+ ;;
71
+ esac
72
+ }
73
+
74
+ __git-flow-release ()
75
+ {
76
+ local curcontext="$curcontext" state line
77
+ typeset -A opt_args
78
+
79
+ _arguments -C \
80
+ ':command:->command' \
81
+ '*::options:->options'
82
+
83
+ case $state in
84
+ (command)
85
+
86
+ local -a subcommands
87
+ subcommands=(
88
+ 'start:Start a new release branch.'
89
+ 'finish:Finish a release branch.'
90
+ 'list:List all your release branches. (Alias to `git flow release`)'
91
+ )
92
+ _describe -t commands 'git flow release' subcommands
93
+ _arguments \
94
+ -v'[Verbose (more) output]'
95
+ ;;
96
+
97
+ (options)
98
+ case $line[1] in
99
+
100
+ (start)
101
+ _arguments \
102
+ -F'[Fetch from origin before performing finish]'\
103
+ ':version:__git_flow_version_list'
104
+ ;;
105
+
106
+ (finish)
107
+ _arguments \
108
+ -F'[Fetch from origin before performing finish]' \
109
+ -s'[Sign the release tag cryptographically]'\
110
+ -u'[Use the given GPG-key for the digital signature (implies -s)]'\
111
+ -m'[Use the given tag message]'\
112
+ -p'[Push to $ORIGIN after performing finish]'\
113
+ ':version:__git_flow_version_list'
114
+ ;;
115
+
116
+ *)
117
+ _arguments \
118
+ -v'[Verbose (more) output]'
119
+ ;;
120
+ esac
121
+ ;;
122
+ esac
123
+ }
124
+
125
+ __git-flow-hotfix ()
126
+ {
127
+ local curcontext="$curcontext" state line
128
+ typeset -A opt_args
129
+
130
+ _arguments -C \
131
+ ':command:->command' \
132
+ '*::options:->options'
133
+
134
+ case $state in
135
+ (command)
136
+
137
+ local -a subcommands
138
+ subcommands=(
139
+ 'start:Start a new hotfix branch.'
140
+ 'finish:Finish a hotfix branch.'
141
+ 'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
142
+ )
143
+ _describe -t commands 'git flow hotfix' subcommands
144
+ _arguments \
145
+ -v'[Verbose (more) output]'
146
+ ;;
147
+
148
+ (options)
149
+ case $line[1] in
150
+
151
+ (start)
152
+ _arguments \
153
+ -F'[Fetch from origin before performing finish]'\
154
+ ':hotfix:__git_flow_version_list'\
155
+ ':branch-name:__git_branch_names'
156
+ ;;
157
+
158
+ (finish)
159
+ _arguments \
160
+ -F'[Fetch from origin before performing finish]' \
161
+ -s'[Sign the release tag cryptographically]'\
162
+ -u'[Use the given GPG-key for the digital signature (implies -s)]'\
163
+ -m'[Use the given tag message]'\
164
+ -p'[Push to $ORIGIN after performing finish]'\
165
+ ':hotfix:__git_flow_hotfix_list'
166
+ ;;
167
+
168
+ *)
169
+ _arguments \
170
+ -v'[Verbose (more) output]'
171
+ ;;
172
+ esac
173
+ ;;
174
+ esac
175
+ }
176
+
177
+ __git-flow-feature ()
178
+ {
179
+ local curcontext="$curcontext" state line
180
+ typeset -A opt_args
181
+
182
+ _arguments -C \
183
+ ':command:->command' \
184
+ '*::options:->options'
185
+
186
+ case $state in
187
+ (command)
188
+
189
+ local -a subcommands
190
+ subcommands=(
191
+ 'start:Start a new feature branch.'
192
+ 'finish:Finish a feature branch.'
193
+ 'list:List all your feature branches. (Alias to `git flow feature`)'
194
+ 'publish: public'
195
+ 'track: track'
196
+ 'diff: diff'
197
+ 'rebase: rebase'
198
+ 'checkout: checkout'
199
+ 'pull: pull'
200
+ )
201
+ _describe -t commands 'git flow feature' subcommands
202
+ _arguments \
203
+ -v'[Verbose (more) output]'
204
+ ;;
205
+
206
+ (options)
207
+ case $line[1] in
208
+
209
+ (start)
210
+ _arguments \
211
+ -F'[Fetch from origin before performing finish]'\
212
+ ':feature:__git_flow_feature_list'\
213
+ ':branch-name:__git_branch_names'
214
+ ;;
215
+
216
+ (finish)
217
+ _arguments \
218
+ -F'[Fetch from origin before performing finish]' \
219
+ -r'[Rebase instead of merge]'\
220
+ ':feature:__git_flow_feature_list'
221
+ ;;
222
+
223
+ (publish)
224
+ _arguments \
225
+ ':feature:__git_flow_feature_list'\
226
+ ;;
227
+
228
+ (track)
229
+ _arguments \
230
+ ':feature:__git_flow_feature_list'\
231
+ ;;
232
+
233
+ (diff)
234
+ _arguments \
235
+ ':branch:__git_branch_names'\
236
+ ;;
237
+
238
+ (rebase)
239
+ _arguments \
240
+ -i'[Do an interactive rebase]' \
241
+ ':branch:__git_branch_names'
242
+ ;;
243
+
244
+ (checkout)
245
+ _arguments \
246
+ ':branch:__git_flow_feature_list'\
247
+ ;;
248
+
249
+ (pull)
250
+ _arguments \
251
+ ':remote:__git_remotes'\
252
+ ':branch:__git_branch_names'
253
+ ;;
254
+
255
+ *)
256
+ _arguments \
257
+ -v'[Verbose (more) output]'
258
+ ;;
259
+ esac
260
+ ;;
261
+ esac
262
+ }
263
+
264
+ __git_flow_version_list ()
265
+ {
266
+ local expl
267
+ declare -a versions
268
+
269
+ versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
270
+ __git_command_successful || return
271
+
272
+ _wanted versions expl 'version' compadd $versions
273
+ }
274
+
275
+ __git_flow_feature_list ()
276
+ {
277
+ local expl
278
+ declare -a features
279
+
280
+ features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
281
+ __git_command_successful || return
282
+
283
+ _wanted features expl 'feature' compadd $features
284
+ }
285
+
286
+ __git_remotes () {
287
+ local expl gitdir remotes
288
+
289
+ gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
290
+ __git_command_successful || return
291
+
292
+ remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
293
+ __git_command_successful || return
294
+
295
+ # TODO: Should combine the two instead of either or.
296
+ if (( $#remotes > 0 )); then
297
+ _wanted remotes expl remote compadd $* - $remotes
298
+ else
299
+ _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
300
+ fi
301
+ }
302
+
303
+ __git_flow_hotfix_list ()
304
+ {
305
+ local expl
306
+ declare -a hotfixes
307
+
308
+ hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
309
+ __git_command_successful || return
310
+
311
+ _wanted hotfixes expl 'hotfix' compadd $hotfixes
312
+ }
313
+
314
+ __git_branch_names () {
315
+ local expl
316
+ declare -a branch_names
317
+
318
+ branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
319
+ __git_command_successful || return
320
+
321
+ _wanted branch-names expl branch-name compadd $* - $branch_names
322
+ }
323
+
324
+ __git_command_successful () {
325
+ if (( ${#pipestatus:#0} > 0 )); then
326
+ _message 'not a git repository'
327
+ return 1
328
+ fi
329
+ return 0
330
+ }
331
+
332
+ zstyle ':completion:*:*:git:*' user-commands flow:'description for foo'
333
+
334
+ alias gf='git flow'
335
+ alias gfi='git flow init'
336
+ alias gff='git flow feature'
337
+ alias gfr='git flow release'
338
+ alias gfb='git flow hotfix'
339
+ alias gfs='git flow support'
340
+ alias gfv='git flow version'
@@ -0,0 +1,183 @@
1
+ #compdef knife
2
+
3
+ # These flags should be available everywhere according to man knife
4
+ knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes )
5
+
6
+ # knife has a very special syntax, some example calls are:
7
+ # knife status
8
+ # knife cookbook list
9
+ # knife role show ROLENAME
10
+ # knife data bag show DATABAGNAME
11
+ # knife role show ROLENAME --attribute ATTRIBUTENAME
12
+ # knife cookbook show COOKBOOKNAME COOKBOOKVERSION recipes
13
+
14
+ # The -Q switch in compadd allow for completions of things like "data bag" without having to go through two rounds of completion and avoids zsh inserting a \ for escaping spaces
15
+ _knife() {
16
+ local curcontext="$curcontext" state line
17
+ typeset -A opt_args
18
+ cloudproviders=(bluebox ec2 rackspace slicehost terremark)
19
+ _arguments \
20
+ '1: :->knifecmd'\
21
+ '2: :->knifesubcmd'\
22
+ '3: :->knifesubcmd2' \
23
+ '4: :->knifesubcmd3' \
24
+ '5: :->knifesubcmd4' \
25
+ '6: :->knifesubcmd5'
26
+
27
+ case $state in
28
+ knifecmd)
29
+ compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" exec environment index node recipe role search ssh status windows $cloudproviders
30
+ ;;
31
+ knifesubcmd)
32
+ case $words[2] in
33
+ (bluebox|ec2|rackspace|slicehost|terremark)
34
+ compadd "$@" server images
35
+ ;;
36
+ client)
37
+ compadd -Q "$@" "bulk delete" list create show delete edit reregister
38
+ ;;
39
+ configure)
40
+ compadd "$@" client
41
+ ;;
42
+ cookbook)
43
+ compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload
44
+ ;;
45
+ environment)
46
+ compadd -Q "$@" list create delete edit show "from file"
47
+ ;;
48
+ node)
49
+ compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
50
+ ;;
51
+ recipe)
52
+ compadd "$@" list
53
+ ;;
54
+ role)
55
+ compadd -Q "$@" "bulk delete" create delete edit "from file" list show
56
+ ;;
57
+ windows)
58
+ compadd "$@" bootstrap
59
+ ;;
60
+ *)
61
+ _arguments '2:Subsubcommands:($(_knife_options1))'
62
+ esac
63
+ ;;
64
+ knifesubcmd2)
65
+ case $words[3] in
66
+ server)
67
+ compadd "$@" list create delete
68
+ ;;
69
+ images)
70
+ compadd "$@" list
71
+ ;;
72
+ site)
73
+ compadd "$@" vendor show share search download list unshare
74
+ ;;
75
+ (show|delete|edit)
76
+ _arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))'
77
+ ;;
78
+ (upload|test)
79
+ _arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)'
80
+ ;;
81
+ list)
82
+ compadd -a "$@" knife_general_flags
83
+ ;;
84
+ bag)
85
+ compadd -Q "$@" show edit list "from file" create delete
86
+ ;;
87
+ *)
88
+ _arguments '3:Subsubcommands:($(_knife_options2))'
89
+ esac
90
+ ;;
91
+ knifesubcmd3)
92
+ case $words[3] in
93
+ show)
94
+ case $words[2] in
95
+ cookbook)
96
+ versioncomp=1
97
+ _arguments '4:Cookbookversions:($(_cookbook_versions) latest)'
98
+ ;;
99
+ (node|client|role)
100
+ compadd "$@" --attribute
101
+ esac
102
+ esac
103
+ case $words[4] in
104
+ (show|edit)
105
+ _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
106
+ ;;
107
+ file)
108
+ _arguments '*:file or directory:_files -g "*.(rb|json)"'
109
+ ;;
110
+ list)
111
+ compadd -a "$@" knife_general_flags
112
+ ;;
113
+ *)
114
+ _arguments '*:Subsubcommands:($(_knife_options3))'
115
+ esac
116
+ ;;
117
+ knifesubcmd4)
118
+ if (( versioncomp > 0 )); then
119
+ compadd "$@" attributes definitions files libraries providers recipes resources templates
120
+ else
121
+ _arguments '*:Subsubcommands:($(_knife_options2))'
122
+ fi
123
+ ;;
124
+ knifesubcmd5)
125
+ _arguments '*:Subsubcommands:($(_knife_options3))'
126
+ esac
127
+ }
128
+
129
+ # Helper functions to provide the argument completion for several depths of commands
130
+ _knife_options1() {
131
+ ( for line in $( knife $words[2] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
132
+ }
133
+
134
+ _knife_options2() {
135
+ ( for line in $( knife $words[2] $words[3] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
136
+ }
137
+
138
+ _knife_options3() {
139
+ ( for line in $( knife $words[2] $words[3] $words[4] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done )
140
+ }
141
+
142
+ # The chef_x_remote functions use knife to get a list of objects of type x on the server
143
+ _chef_roles_remote() {
144
+ (knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
145
+ }
146
+
147
+ _chef_clients_remote() {
148
+ (knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
149
+ }
150
+
151
+ _chef_nodes_remote() {
152
+ (knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
153
+ }
154
+
155
+ _chef_cookbooks_remote() {
156
+ (knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
157
+ }
158
+
159
+ _chef_sitecookbooks_remote() {
160
+ (knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
161
+ }
162
+
163
+ _chef_data_bags_remote() {
164
+ (knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
165
+ }
166
+
167
+ _chef_environments_remote() {
168
+ (knife environment list | awk '{print $1}')
169
+ }
170
+
171
+ # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
172
+ _chef_cookbooks_local() {
173
+ (for i in $( grep cookbook_path $HOME/.chef/knife.rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' ); do ls $i; done)
174
+ }
175
+
176
+ # This function extracts the available cookbook versions on the chef server
177
+ _cookbook_versions() {
178
+ (knife cookbook show $words[4] | grep -v $words[4] | grep -v -E '\]|\[|\{|\}' | sed 's/ //g' | sed 's/"//g')
179
+ }
180
+
181
+ _knife "$@"
182
+
183
+ alias knife='nocorrect knife'
@@ -0,0 +1 @@
1
+ alias k='nocorrect bundle exec knife'
@@ -0,0 +1,13 @@
1
+ # Quick alias to edit a directory with MacVim. Requires macvim_drawer
2
+ # from Homebrew: https://gist.github.com/3076384
3
+ e() {
4
+ if [[ -f "$PWD/README.md" ]] ; then
5
+ mvim README.md
6
+ elif [[ -f "$PWD/README.rdoc" ]] ; then
7
+ mvim README.rdoc
8
+ elif [[ -f "$PWD/README.textile" ]] ; then
9
+ mvim README.textile
10
+ else
11
+ mvim .
12
+ fi
13
+ }
@@ -0,0 +1,5 @@
1
+ #compdef man-preview
2
+ #autoload
3
+
4
+ _man
5
+
@@ -0,0 +1,101 @@
1
+ # ------------------------------------------------------------------------------
2
+ # FILE: osx.plugin.zsh
3
+ # DESCRIPTION: oh-my-zsh plugin file.
4
+ # AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com)
5
+ # VERSION: 1.0.1
6
+ # ------------------------------------------------------------------------------
7
+
8
+
9
+ function tab() {
10
+ local command="cd \\\"$PWD\\\""
11
+ (( $# > 0 )) && command="${command}; $*"
12
+
13
+ the_app=$(
14
+ osascript 2>/dev/null <<EOF
15
+ tell application "System Events"
16
+ name of first item of (every process whose frontmost is true)
17
+ end tell
18
+ EOF
19
+ )
20
+
21
+ [[ "$the_app" == 'Terminal' ]] && {
22
+ osascript 2>/dev/null <<EOF
23
+ tell application "System Events"
24
+ tell process "Terminal" to keystroke "t" using command down
25
+ tell application "Terminal" to do script "${command}" in front window
26
+ end tell
27
+ EOF
28
+ }
29
+
30
+ [[ "$the_app" == 'iTerm' ]] && {
31
+ osascript 2>/dev/null <<EOF
32
+ tell application "iTerm"
33
+ set current_terminal to current terminal
34
+ tell current_terminal
35
+ launch session "Default Session"
36
+ set current_session to current session
37
+ tell current_session
38
+ write text "${command}"
39
+ end tell
40
+ end tell
41
+ end tell
42
+ EOF
43
+ }
44
+ }
45
+
46
+ function pfd() {
47
+ osascript 2>/dev/null <<EOF
48
+ tell application "Finder"
49
+ return POSIX path of (target of window 1 as alias)
50
+ end tell
51
+ EOF
52
+ }
53
+
54
+ function pfs() {
55
+ osascript 2>/dev/null <<EOF
56
+ set output to ""
57
+ tell application "Finder" to set the_selection to selection
58
+ set item_count to count the_selection
59
+ repeat with item_index from 1 to count the_selection
60
+ if item_index is less than item_count then set the_delimiter to "\n"
61
+ if item_index is item_count then set the_delimiter to ""
62
+ set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
63
+ end repeat
64
+ EOF
65
+ }
66
+
67
+ function cdf() {
68
+ cd "$(pfd)"
69
+ }
70
+
71
+ function pushdf() {
72
+ pushd "$(pfd)"
73
+ }
74
+
75
+ function quick-look() {
76
+ (( $# > 0 )) && qlmanage -p $* &>/dev/null &
77
+ }
78
+
79
+ function man-preview() {
80
+ man -t "$@" | open -f -a Preview
81
+ }
82
+
83
+ function trash() {
84
+ local trash_dir="${HOME}/.Trash"
85
+ local temp_ifs=$IFS
86
+ IFS=$'\n'
87
+ for item in "$@"; do
88
+ if [[ -e "$item" ]]; then
89
+ item_name="$(basename $item)"
90
+ if [[ -e "${trash_dir}/${item_name}" ]]; then
91
+ mv -f "$item" "${trash_dir}/${item_name} $(date "+%H-%M-%S")"
92
+ else
93
+ mv -f "$item" "${trash_dir}/"
94
+ fi
95
+ fi
96
+ done
97
+ IFS=$temp_ifs
98
+ }
99
+
100
+ alias ql='quick-look'
101
+ alias osx_for_hackers='source $ZSH/lib/plugins/osx/osx_for_hackers.zsh'