New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zsh-syntax-highlighting does not like the alias '=' #263
Comments
Can you show us the code that defines the alias? Is it
I would. The potential downside is that it requires the zsh/parameter module, but I think in practice everyone has that module... so, I propose we start requiring the module, and if somebody then speaks up saying their zsh doesn't have the module, revisit the decision. Thanks for the report! |
Added the |
On Wed, Jan 6, 2016 at 14:27 (-0800), Daniel Shahaf wrote:
Cheers.
|
This patch makes the error (after creating diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
index bc6e2bb..5c1ceb9 100644
--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -295,7 +295,13 @@ _zsh_highlight_main_highlighter()
style=$ZSH_HIGHLIGHT_STYLES[suffix-alias]
;;
*': alias') style=$ZSH_HIGHLIGHT_STYLES[alias]
- local aliased_command="${"$(alias -- $arg)"#*=}"
+ local aliased_command
+ if zmodload -e zsh/parameter; then
+ (( $+aliases )) || { zle -M "$0: zsh/parameter does not define \$aliases" }
+ aliased_command=${aliases[$arg]}
+ else
+ aliased_command="${"$(alias -- $arg)"#*=}"
+ fi
[[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg)
;;
*': builtin') style=$ZSH_HIGHLIGHT_STYLES[builtin];; Remaining work:
|
Upstream says (in workers/37545) that assignments to $aliases directly are not supported, they may break some functionality, if it breaks you get to keep both pieces. |
On Sun, Jan 10, 2016 at 12:28 (-0800), Daniel Shahaf wrote:
That's true, although the given example of trying to alias "x=y" to Anyway, thanks again for looking at it.
|
Yes and no. Trying to run the command |
This will happen as part of #298. |
I have a function called '=' and an alias for = which is 'noglob ='.
(I find it very useful to be able to type things like
= 417 99 2 k /
and have it tell me
4.21
)
and '=' not only seems like a nice alias for this, but is what I used for many years with tcsh before I started using zsh.
Anyway, there is a line in main-highlighter.zsh
local aliased_command="${"$(alias -- $arg)"#*=}"
which gets upset if you have an alias like '='. However, the line
local aliased_command="$aliases[$arg]"
seems to work for = and other aliases (in my tests), and is (arguably)
a bit more succinct and clearer.
Would you consider including it in the main branch?
Thanks.
The text was updated successfully, but these errors were encountered: