terlar · GitHub

Right now it only takes a function name which is a little bit cumbersome if you want to use a custom prompt for a specific use case. The worst part is you have to come up with some name for your prompt and you litter your functions.

Current use case:

function dangerous_function
  function continue_prompt
    echo 'Do you want to continue? [Y/n]'
  end
  echo 'I will do dangerous stuff'
  read -l -p continue_prompt continue
  if test $continue = 'Y' -o $continue = 'y'
    echo 'Do dangerous stuff'
  end
end

If we let -p take a string instead people could use a function if they want by using parenthesis, -p (continue_prompt).

function dangerous_function
  echo 'I will do dangerous stuff'
  read -l -p 'Do you want to continue? [Y/n]' continue
  if test $continue = 'Y' -o $continue = 'y'
    echo 'Do dangerous stuff'
  end
end

Read the original on github.com ↗