I log to file everything from my Bash console. I do it with the following code added to my .bashrc
:
start_terminal_logging(){ if [ -z "$SCRIPT_LOG_FILE_ACTIVE" ]; then # Log each session to a separate file: logdir=~/.terminal_logs logfile=$logdir/session_log_$(date +%Y%m%d_%H%M%S)_$$.txt # If no folder exist make one: if [ ! -d $logdir ]; then mkdir -p $logdir fi export SCRIPT_LOG_FILE_ACTIVE=$logfile # Start logging, a=append, q=quiet: script -aq $logfile exit fi}# Start the logging(script above):start_terminal_logging
This creates a file session_log_$datetime.txt
for each terminal session, and saves everything into it.
However, when I launch the terminal from within VS Code, it doesn't work. How can I log VS Code terminal outputs into file too?