Edit shell variables interactively in zsh

2022 Oct 02

When you write and edit a command to execute in zsh, you’re using zshzle, its command line editor. zshzle sets up keybindings like <Ctrl-b> to move the cursor back one character, and <Ctrl-r> to search command history.

In zsh, use zle’s vared built-in to quickly set a variable’s value interactively. vared pastes the variable’s current value in a command line ready for you to edit. When you hit <Return>, the line you’ve edited is set. It even works for arrays, like path.

References: