From 899c83d0cd30431c796317d352233507c8360891 Mon Sep 17 00:00:00 2001 From: Andreas Jaggi Date: Sat, 25 Dec 2010 22:38:07 +0100 Subject: [PATCH] Underline text at curor if matching path exists --- zsh-syntax-highlighting.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index ba298be..7bf6172 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -24,6 +24,14 @@ ZLE_DEFAULT='fg=white,bold' ZLE_TOKENS_FOLLOWED_BY_COMMANDS=('|' '||' ';' '&' '&&' 'sudo' 'start' 'time' 'strace' 'ยง') +_check_path() { + [ -z "$arg" ] && return 1 + [ -e $arg ] && return 0 + [ ! -e "`dirname $arg`" ] && return 1 + [ ${#BUFFER} = $end_pos -a -n "`print $arg*`" ] && return 0 + return 1 +} + # Recolorize the current ZLE buffer. colorize-zle-buffer() { region_highlight=() @@ -43,7 +51,7 @@ colorize-zle-buffer() { *"$cmd is"*) style=$ZLE_COMMAND_STYLE;; *) style=$ZLE_COMMAND_UNKNOWN_TOKEN_STYLE - [ -e "$arg" ] && style=$ZLE_PATH_STYLE + _check_path && style=$ZLE_PATH_STYLE ;; esac else @@ -56,7 +64,7 @@ colorize-zle-buffer() { *"*"*) style=$ZLE_GLOBING;; *) style=$ZLE_DEFAULT - [ -e "$arg" ] && style=$ZLE_PATH_STYLE + _check_path && style=$ZLE_PATH_STYLE ;; esac fi