Run script from .bash_profile for first Terminal tab/window only
Solution 1:
If this script starts an application/binary, the usual way to prevent several executions is to first check whether that binary is already running (man ps
or man psgrep
might help) and only launch it if it isn't already started.
As an alternative you could look into LaunchAgents to start the binary directly when you log in (and even have it restarted automatically in case it crashes).