I'd like to store a value in an environment variable, but I don't want to do it like this
VAR_NAME=secretvalue, because then it will be stored in the shell's history file. Is there a way to prompt me for the value, just like
If you have the password in the clipboard, use
pbpaste. See Any function copying from clipboard to a variable in Bash?
Otherwise, assuming that the secret value doesn't contain any newlines (or any control characters or characters that you can't type):
printf 'Password: ' IFS= read -r VAR_NAME
Many shells let you pass the prompt directly to
IFS= read -p 'Password: ' -r VAR_NAME
If you don't want the secret to be visible on your terminal, see Reading passwords without showing on screen in Bash Scripts. Note that even without this, the password won't be saved anywhere once you clear your terminal.