Skip to content

Disable path checking by directory #379

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

Closed
4 tasks
danielshahaf opened this issue Oct 11, 2016 · 3 comments · Fixed by #496
Closed
4 tasks

Disable path checking by directory #379

danielshahaf opened this issue Oct 11, 2016 · 3 comments · Fixed by #496

Comments

@danielshahaf
Copy link
Member

RFE: Disable path checking for some directories but not others. Similar to the vcs_info disable-patterns style. This would be useful under expensive-to-readdir()/stat() mountpoints (e.g., sshfs).

This would need to check several things:

  • Absolute filenames under DIR: % stat /victim/foo/bar
  • Relative paths that resolve to paths under DIR (could use the :a modifier here, since it's disk-agnostic): % stat ../victim/foo/bar
  • Any paths, when cwd is DIR: /victim% stat foo (where the prompt displays cwd)
  • Any of the foregoing, as a command word: % /victim/foo/bar
@danielshahaf
Copy link
Member Author

Tentatively adding to 0.7.0 milestone.

@phy1729
Copy link
Member

phy1729 commented Jan 21, 2018

Any suggested array name? I think something like this would do the trick.

diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
index b8ed1a5..a3bdcf4 100644
--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -764,6 +764,13 @@ _zsh_highlight_main_highlighter_check_path()
   [[ -L $expanded_path ]] && return 0
   [[ -e $expanded_path ]] && return 0
 
+  # Check if this is a disallowed path
+  local path=$expanded_path:P
+  while [[ $path != / ]]; do
+    [[ -z ${path:|ZSH_HIGHLIGHT_XXX} ]] && return 1
+    path=$path:h
+  done
+
   # Search the path in CDPATH
   local cdpath_dir
   for cdpath_dir in $cdpath ; do

@danielshahaf
Copy link
Member Author

XXX = DIRS_BLACKLIST

:P requires a new zsh, also it can access disk (as can the [[ tests right above) so we need to be careful, is just readdir() expensive or also stat()?

Making path local requires -h (-H?).

Excuse brevity.

phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Jan 21, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Feb 7, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Feb 11, 2018
phy1729 added a commit to phy1729/zsh-syntax-highlighting that referenced this issue Feb 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants