SnakeDoc's answer might work if you can force all shells to be login shells. If you are connecting ti a remote server via ssh for example. If this is your local machine and you want script
to be run every time you open a terminal, the only way I can think of is using the terminal's settings.
For example, using my personal favorite terminal (terminator, on debian installable with sudo apt-get install terminator
), you can set a specific command to be run when opening a terminal. Open ~/.config/terminator/config
and add these lines to the [[default]]
profile:
use_custom_command = True
custom_command = script -a
You can also set it up so that script
is only run for a specific profile. Add these lines after the [[default]]
profile:
[[script]]
use_custom_command = True
custom_command = script -a
This creates a new profile called script
which you can run by executing terminator -p script
.
On gnome-terminal
, you can do the same as follows:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/0LiXu.png)