Skip to content
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

Support sudo aliases #247

Closed
dffischer opened this issue Dec 3, 2015 · 4 comments
Closed

Support sudo aliases #247

dffischer opened this issue Dec 3, 2015 · 4 comments
Labels

Comments

@dffischer
Copy link

Many users have an alias set up to map the sudo command to something even shorter. It would be great if this could be treated like sudo itself, in terms of highlighting the alias as well as the following commands.

danielshahaf added a commit to danielshahaf/zsh-syntax-highlighting that referenced this issue Dec 4, 2015
@danielshahaf
Copy link
Member

Please try the branch I just pushed. I tested it with alias xxx="sudo".

This approach will DTRT even if if flags are passed to sudo through the alias, e.g., xxx -u foo ls.

Cross-referencing #168.

@dffischer
Copy link
Author

This works fine with arbitrary aliases for sudo.

Aliases with trailing spaces do not yet work, but I opened a separate issue #249 for this problem.

@danielshahaf
Copy link
Member

After alias sudo_nospace=sudo sudo_withspace="sudo ", this branch colors the middle word in sudo_nospace sudo_withspace ls in green. The correct thing would be to highlight it in red (since aliases are not supposed to be looked up at that position), but since the code doesn't know yet that sudo_nospace foo shouldn't consider foo as a potential alias, I expected the code to highlight sudo_withspace in green-underline in this case.

(That's after fixing the newly-added condition to match both sudo and "sudo ".)

I'd like to understand this discrepancy.

I'd also like to consider whether there is a cheap way of implementing a more general alias expansion solution — perhaps have the main command word case statement do the alias lookup first, and potentially check if the expansion is one word (via ${(z)…} on the expansion) — and whether this lookup would have performance consequences for more complicated cases (#240).

@danielshahaf
Copy link
Member

The concerns in the last post are mooted by the alias refactorings on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants