In my Bash terminal, I regularly execute a chain of commands. For example:
cmd1 && cmd2 && cmd3
Now, I want to define an environment variable which is applied to all three commands and which only scoped to those commands. I tried:
MY_VAR=abc cmd1 && cmd2 && cmd3
But it seems that now only cmd1
sees MY_VAR
.
Is there a way to apply the environment variable to all three commands? I know I could export
in advance, but I prefer to declare the environment variable locally in an ad-hoc fashion, so it will never impact subsequent commands.
It it matters, I am using urxvt
as terminal emulator.