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:
1This will only work if the user starts a login, non-interactive shell. Normally, opening a terminal runs an interactive shell so this will not work. Oh, and to do it for all users, just edit
/etc/profile
. – terdon – 2013-03-13T17:18:43.883