Skip to content

Instantly share code, notes, and snippets.

@joseph
Created September 26, 2012 08:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseph/3786773 to your computer and use it in GitHub Desktop.
Save joseph/3786773 to your computer and use it in GitHub Desktop.
Screen for vagrant
#==============================================================================
# MASTER SCREENRC FILE
# This contains the default 'screen' settings I like to use across all
# environments.
# Created: 4 Nov 2006
# Author: Joseph Pearson
# Based to a greater or lesser extent on various resources on the 'net.
#------------------------------------------------------------------------------
startup_message off
#caption always "%-Lw%{= BW}%50>%h%f* %t%{-}%+Lw%<"
caption always "%{Kb}%L=%-w%45>%{bK}%n %t%{-}%+w%-0<"
autodetach on
defscrollback 10000
altscreen on
# F7/F8 to navigate through screen windows.
bindkey -k k7 prev
bindkey -k k8 next
# Don't close a window when its starting process dies.
zombie kr
# remap Ctrl-a to Ctrl p -- I like Ctrl-a to take me to start of line.
escape ^pp
bindkey -k k6 copy
term xterm-color
# load my aliases and stuff
shell -bash
#------------------------------------------------------------------------------
# XTERM TWEAKS
# scrollback buffer goes into Terminal.app's buffer
termcapinfo xterm*|rxvt* 'ti@:te@'
#xterm understands both im/ic and doesn't have a status line.
#Note: Do not specify im and ic in the real termcap/info file as
#some programs (e.g. vi) will not work anymore.
termcap xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l
terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l
#80/132 column switching must be enabled for ^AW to work
#change init sequence to not switch width
termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l
# Make the output buffer large for (fast) xterms.
termcapinfo xterm* OL=10000
# tell screen that xterm can switch to dark background and has function keys.
termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l'
termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'
termcapinfo xterm 'kh=\EOH:kI=\E[2~:kD=\E[3~:kH=\EOF:kP=\E[5~:kN=\E[6~'
# special xterm hardstatus: use the window title.
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'
terminfo xterm 'vb=\E[?5h$<200/>\E[?5l'
termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l'
# emulate part of the 'K' charset
termcapinfo xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337'
# xterm-52 tweaks:
# - uses background color for delete operations
termcapinfo xterm* be
# Load the master screenrc file!
source $HOME/.master.screenrc
# Create screens for the various development tasks:
screen -t 'server' 1 ssh project-vagrant -t 'cd /vagrant; unicorn -p 3227'
screen -t 'search' 2 ssh project-vagrant -t 'cd /vagrant; rake ts:restart NODETACH=true --trace'
screen -t 'jobs' 3 ssh project-vagrant -t 'cd /vagrant; rake jobs:work --trace'
screen -t 'postgres' 4 ssh project-vagrant -t 'cd /vagrant; script/rails dbconsole'
screen -t 'irb' 5 ssh project-vagrant -t 'cd /vagrant; script/rails console'
screen -t 'ssh' 6 ssh project-vagrant -t 'cd /vagrant; /bin/bash -l -i'
screen -t 'commands' 7 /bin/bash -l -i
#!/bin/sh
# Start GNU screen with project-specific configuration.
if test -f ".screenrc"; then
screen -c .screenrc
else
echo "You are not in a project directory."
fi
Vagrant::Config.run do |c|
c.vm.box = 'base'
c.vm.host_name = 'project-vagrant'
c.vm.customize(['modifyvm', :id, '--memory', 768])
c.vm.customize ["modifyvm", :id, "--rtcuseutc", "on"]
c.vm.forward_port(22, 2227)
c.vm.network(:hostonly, '192.168.22.27')
c.ssh.forward_agent = true
end
@joseph
Copy link
Author

joseph commented Sep 26, 2012

The .master.screenrc goes in $HOME, and sc goes in your $PATH with a chmod +x. Then:

$ cd ~/project
$ vagrant up
$ sc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment