Created
September 27, 2012 01:22
-
-
Save pvinis/3791646 to your computer and use it in GitHub Desktop.
shell recording
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for spyshell | |
function zshexit() { | |
cat /Users/`whoami`/.termlogs/`date +%Y-%m-%d`.txt | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' | col -b > temp | |
mv temp /Users/`whoami`/.termlogs/`date +%Y-%m-%d`.txt | |
exit | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This will help you to record everything you input and all output from your terminal to a file, while you work on your terminal normally. | |
First, put spyshell in /usr/local/bin/ | |
Add the line /usr/local/bin/spyshell in the file /etc/shells | |
Do `chsh -s /usr/local/bin/spyshell` | |
Add the zshexit function in your .zshrc file. | |
This will create a file in ~/.termlogs/ named with the date, and will append till the day is over. The output is also stripped from any non-printable characters. | |
You can modify it so that it launches bash, or any other shell, change the location of the logs, as well as the names. | |
credits: a gist I cannot find, and a lot googling.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
script="/usr/bin/script" | |
SHELL="/usr/local/bin/zsh" | |
if [ -z "$SPYSHELL" ]; then | |
export SPYSHELL=yes | |
$script -aq -t 0 /Users/`whoami`/.termlogs/`date +%Y-%m-%d`.txt | |
else | |
exec $SHELL | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot for putting this together! I had to execute a few additional commands.
spyshell
executable:chmod +x /usr/local/bin/spyshell
termlogs
directory:mkdir ~/.termlogs
I also had to use
sudo
to modify/etc/shells
: (sudo vim /etc/shells
).