This function can be used to help user input a modification of some text.

 function change { bash -c "read -ei \"$1\" temp && echo \$temp" }

What is idiomatic zsh way to do something similar?


With the vared builtin.

change () {
  local temp=$1
  vared temp
  print -lr -- $temp

And if you want to use the string entered by the user later in your script, it's just

temp='initial value'
vared temp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.