zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
20k stars 1.33k forks source link

Jobs in command position #874

Open danielshahaf opened 2 years ago

danielshahaf commented 2 years ago

The various percent syntaxes for referring to a job (https://zsh.sourceforge.io/Doc/Release/Jobs-_0026-Signals.html#Jobs) can be used in command position to foreground that job:

% cat & 
[1] 9896
% 
[1]  + suspended (tty input)  cat
% %cat
[1]  + continued  cat

In the example, %cat should be green, even if there's no alias/function/builtin of that name.

Cf. https://zsh.org/users/27806 (user ran into this in zsh upstream).

thisisrandy commented 4 months ago

It's possible to work around this using the regexp highlighter. Here's a rough cut:

ZSH_HIGHLIGHT_HIGHLIGHTERS+=(regexp)
ZSH_HIGHLIGHT_REGEXP+=('^%\S*' fg=green)