I just gave a talk on screen. I walked through
integration with bash, vim, and mutt. For bash, I wanted the name of the box I ssh'd to show up in my hardtitle not that
I'd ssh'd there.
screen_resume() {
prompt_network 'stop'
exec ssh-agent -a ${SSH_AUTH_SOCK} screen -R
}
screen_show_in_shelltitle() {
printf "\ek$*\e\134"
}
screen_run() {
# pretty print $1 as needed
if [[ ! -z "$STY" ]]; then
string_to_show=$(echo $1 | sed -e 's/\..*//' )
screen_show_in_shelltitle ${string_to_show}
fi
shift
command $*
}
ssh() { screen_run $1 ssh $@ ; }
telnet() { screen_run $1 telnet $@ ; }
exec() { screen_run $1 exec $@ ; }
sudo() { screen_run $1 sudo $@ ; }
When setting up your bash prompt, don't actually put the screen escape codes in your PS1 as bash/readline can get confused about how many characters are on the screen and your readline will mangle multi-line commands, so just print them to stdout.
For vim, I just followed up with screen -X readbuf some_file and screen -X paste . for VimREPL
Mutt just needs a new editor, the following script:
#!/bin/sh screen -X select vim vim --servername local --remote-wait "$1" screen -X select mutt
Just name your vim and mutt sessions accordingly, and start your vim up with vim --servername local.
Did I miss a cool use of vim? Let me know....