Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
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 Mar 13 '13 at 17:18
1  
thanks for the /etc/profile suggestion @terdon –  SnakeDoc Mar 13 '13 at 19:06

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.