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

Patch to color more correctly the command behind "sudo" #610

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Raizo62
Copy link

@Raizo62 Raizo62 commented Mar 31, 2019

if the command is sudo foo with :

  • ZSH_HIGHLIGHT_SPECIAL_PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    if foo is in the PATH ${ZSH_HIGHLIGHT_SPECIAL_PATH} then it is green
  • ZSH_HIGHLIGHT_SPECIAL_PATH=""
    foo is red
  • ZSH_HIGHLIGHT_SPECIAL_COMMAND=(brctl ls)
    Only if foo is brctl or ls then foo is green ; other are red
  • (nothing) :
    default behavior

…nge of PATH can't modify the behavior of the commands in "zsh_highlight_main__type"

In _zsh_highlight_main__type :
 - the calls to "builtin type -w -- $1" are replaced by call to "sh_highlight_main__test_type_builtin"
 - if ZSH_HIGHLIGHT_SPECIAL_PATH exists but is empty, "foo" in "sudo foo" is always red
 - if ZSH_HIGHLIGHT_SPECIAL_PATH is not empty, zsh searchs in the PATH "ZSH_HIGHLIGHT_SPECIAL_PATH" to know if the command "foo" in "sudo foo" exists
 - if "foo" is in ZSH_HIGHLIGHT_SPECIAL_COMMAND then "Admin" says that user has access to this command : foo in "sudo foo" is green
@danielshahaf
Copy link
Member

Discussed on #592.

@Raizo62 I'll review later.

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

Successfully merging this pull request may close these issues.

None yet

2 participants