4c409b0de918e62f9354cbc604c6ae65da611caf

Author
Paul Melnikow <paul.melnikow@bodylabs.com>
Committer
ncanceill <nicolas.canceill@ens-cachan.org>
Date

Message

sublime: Make subl a function so it can be called from functions in other modules

Without this change, whether a function can invoke 'subl' depends on the order in which modules are loaded. With this change, the order doesn't matter.

zsh resolves aliases at parse time not run time, which means if you invoke an alias from a function, the alias must be defined before the function.

See http://stackoverflow.com/a/25532276/893113 which refers to an explanation of this limitation.

For code which may be used non-interactively, the recommend workaround is to use functions instead of aliases.

Diff

 1diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
 2index 4d997996038200bea9fe13be44f1ab282684f19a..3e338e4d301bd1df47340a941d5c40023af9f716 100644
 3--- a/plugins/sublime/sublime.plugin.zsh
 4+++ b/plugins/sublime/sublime.plugin.zsh
 5@@ -34,7 +34,7 @@ elif  [[ "$OSTYPE" = darwin* ]]; then
 6 
 7     for _sublime_path in $_sublime_darwin_paths; do
 8         if [[ -a $_sublime_path ]]; then
 9-            alias subl="'$_sublime_path'"
10+            subl () { "$_sublime_path" $* }
11             alias st=subl
12             break
13         fi