Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Safety guards for typos



Phil Pennock wrote on Sun, Jan 23, 2022 at 19:17:36 -0500:
> Instead of:
> 
>     mv *(.) old-2022-01-23/
> 
> I typed:
> 
>     mv *() old-2021-01-24/

A syntax highlighting plugin <disclaimer>which I co-maintain</disclaimer>
would highlight the two cases differently:

[[[
% tests/generate.zsh 'mv *(.) foo/' main users-27486a
⋮
BUFFER=$'mv *(.) foo/'

expected_region_highlight=(
  '1 2 command' # mv
  '4 7 default' # *(.)
  '4 4 globbing' # *
  '9 12 default' # foo/
)
% tests/generate.zsh 'mv *() bar/' main users-27486b
⋮
BUFFER=$'mv *() bar/'

expected_region_highlight=(
  '1 2 command' # mv
  '4 4 default' # *
  '4 4 globbing' # *
  '5 6 reserved-word' # ()
  '8 11 unknown-token' # bar/
)
% 
]]]

So, in the second case you'd see the «()» in yellow and the directory
name in red (or, if AUTO_CD is set, green).

https://github.com/zsh-users/zsh-syntax-highlighting/

Cheers,

Daniel




Messages sorted by: Reverse Date, Date, Thread, Author