3

script command allows to log gently everything that was put to console during session (like history but also displays results of commands). Everything is logged to file typescript.xxx

Now I want to run it in every terminal session that has been runned. I was trying to put script to bashrc but it falls into recursive loop (script is running it's own shell). Any ideas?

2 Answers 2

1

add to

vi ~/.bash_profile

add

exec script

to the bottom (so it's the last thing loaded at login).

You will have to do this for every user though... but should get the job done.

1
  • 1
    This 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
    Commented Mar 13, 2013 at 17:18
1

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 enter image description here enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .