A variable set in one environment cannot be accessed in parent or other (non-child) shells. The following will work:
$my_variable will not be accessible in another terminal, unless you put these lines in some file (e.g.
.bashrc or a file executable by
Another option is to use
fish -c "set -u my_variable 'testing...'"
You can read more here
-U or --universal causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell.
Not sure what exactly is your requirement, but just out of curiosity: if you are concerned about the contents of the variable being accessible / readable, you can write the data to a file and set the permissions to
--x------ and put the file in