Prezto: sudo alias and nocorrect/noglob

Created on 10 Jan 2014  Â·  8Comments  Â·  Source: sorin-ionescu/prezto

Hello,

I was having an issue with aliases not working with sudo, so I found this little trick and it seemed to work fine, until I found it didn't work very well with aliases defined in the utility module.

So basically when the sudo alias is defined I get sudo: nocorrect: command not found on aliases with nocorrect/noglob but other aliases work fine, and if it's not, aliases are unknown when sudoing, is there a way to have both work ?

Any help appreciated, thanks.

Discussion

Most helpful comment

I have a cheap trick to solve this issue, what I did was create a shell file /sbin/nocorrect

#!/bin/sh
exec $*

and I added /sbin to the end of $PATH in /root/.zshrc.

All 8 comments

I tried for a long time trying to solve this... I couldn't, so in the end when I need sudo before any of the described commands, I started doing:

\_ rm # or \sudo rm

I believe using =sudo equally works. What you are doing it's basically "bypassing" alias and defined functions and using the original command.

If you want to work to solve it, you probably want to learn about zle widgets (man zshzle), which is basically the zsh command line editor. You can do amazing things like this.

Aliases do not work with sudo. However, if you have a convoluted command aliased, you can use sudo $aliases[name] instead.

@sorin-ionescu sorry, but I don't understand why do you say they don't?

; alias top=htop
; sudo to<TAB>
; sudo top
# htop it's opened (with root privileges)

They do work with the trick I mentioned, though for some reason nocorrect/noglob are not recognized.
I'm already using the backslash but I can't get used to it, so I always have to run commands twice on these nocorrect/glob aliases.

I know of no way other than to remove nocorrect, noglob, which I will not do; you are free, however to do so in your fork.

On Jan 10, 2014, at 15:08, Nicolas Morel [email protected] wrote:

They do work with the trick I mentioned, though for some reason nocorrect/noglob are not recognized.
I'm already using the backslash but I can't get used to it, so I always have to run commands twice on these nocorrect/glob aliases.

—
Reply to this email directly or view it on GitHub.

@Marsup, I'm pretty sure zle can check and disable nocorrect and noglob on the fly.

@PaBLoX-CL I'm not sure it's possible, zle seems to be about inline modifications of the command line, the problem lies in how zsh interprets it. I could rearrange the command however I want that would not make it work. Anyway thanks for the suggestion.
I've spent a bit of time digging through google and such, I couldn't find anyone who managed to do this, so I guess I'm done here :(

I have a cheap trick to solve this issue, what I did was create a shell file /sbin/nocorrect

#!/bin/sh
exec $*

and I added /sbin to the end of $PATH in /root/.zshrc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TsichiChang picture TsichiChang  Â·  3Comments

daiyanze picture daiyanze  Â·  4Comments

brycekellogg picture brycekellogg  Â·  4Comments

EllieRagone picture EllieRagone  Â·  4Comments

mischaboldy picture mischaboldy  Â·  3Comments