Wednesday, November 19, 2014

How log all input and output in a terminal session?

When you are ready to start recording a log file, type:
script screen.log
Now, until you stop the script, all input and output in the Terminal will be stored in screen.log. When you are done, just type:
exit
Your screen.log file will be in your Home folder (/home/user). This will do exactly what you are looking for.

Monday, November 17, 2014

Screen reconnecting ssh_agent

Its very annoying when after reconnecting abandoned screen tabs, you realize that your command fails because ssh keys are not working. This is a solution that works for me, my ~/.bashrc file:
CURRENT_SSH_AUTH_SOCK=$(find /tmp/ssh-* -user `whoami` \
-name agent\* -printf '%T@ %p\n' 2>/dev/null |\
 sort -k 1nr | sed 's/^[^ ]* //' | head -n 1 )

[ -S "$CURRENT_SSH_AUTH_SOCK" ] && \
ln -sfv $CURRENT_SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock &>/dev/null

[ "$TERM" == "screen" ] && export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock

Sunday, November 16, 2014

Scroll up in GNU screen

Most often answer I found is to is to use screen copy mode
CTRL-A + [
However best works for me adding to ~/.screenrc
termcapinfo xterm ti@:te@
termcapinfo xterm-color ti@:te@
This will let use the terminal application scroll bar

Friday, November 14, 2014

Vi delete commands quick reference.

x   - delete current character
dw  - delete current word
dd  - delete current line
5dd - delete five lines
d$  - delete to end of line
d0  - delete to beginning of line
:1,.d delete to beginning of file
:.,$d delete to end of file