Skip to content

Instantly share code, notes, and snippets.

@rustyio
Created June 17, 2010 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rustyio/442919 to your computer and use it in GitHub Desktop.
Save rustyio/442919 to your computer and use it in GitHub Desktop.
# Emacs-style Window Management
# - Descriptions below use Emacs terminology.
escape ^Xx # Use C-x to start all commands...
bind c detach # C-x c - Detach screen session
bind ^c detach # C-x C-c - Detach screen session
bind f screen # C-x f - New buffer
bind ^f screen # C-x C-f - New buffer
bind k kill # C-x k - Kill current buffer
bind b other # C-x b - Switch to last buffer
bind ^b windowlist # C-x C-b - List all buffers
bind o focus # C-x o - Switch to next window
bindkey -d ^O focus # C-o - Switch to next window
bind 1 only # C-x 1 - Show only the current window
bind 2 split # C-x 2 - Split windows
bind 0 remove # C-x 0 - Close the current window
bind ^x meta # C-x C-x - Pressing C-x twice sends C-x to the buffer
# Use M-x to enter free-form commands...
bindkey -t -d ^[x colon
# Use Emacs Keybindings for Copy/Paste mode
# C-f - Forward one character
# C-b - Backward one character
# C-n - Down one line
# C-p - Up one line
# C-a - Start of line
# C-e - End of line
markkeys h=^b:l=^f:j=^n:k=^p:0=^a:$=^e
markkeys ' '=^@
# Special hack for C-e, since it should go *past*
# the last char. -m means this is for copy mode only.
bindkey -m ^e stuff "$^f"
bindkey -m ^[b stuff "b"
bindkey -m ^[f stuff "w"
# In copy mode, a control W copies and writes to clipboard.
bindkey -m ^w eval "stuff \" \"" "writebuf /tmp/screen-pbcopy" "exec /usr/bin/osascript -e 'tell application \"System Events\"' -e 'set the clipboard to (read posix file \"/tmp/screen-pbcopy\" as text)' -e 'end tell'"
# In copy mody, use C-<space> to set mark.
bindkey -d ^@ stuff " "
# Disable C-g, usually toggles the bell. I reflexively hit this alot
# because of Emacs.
bind ^g stuff "^g"
# Change title with C-x C-t
bind t title
# Uncomment these to use arrow keys to change window sizes.
# Use C-p or C-n to take the place of arrow keys.
#bindkey -k ku resize -1
#bindkey -k kd resize +1
# Set up UI
defscrollback 20000
startup_message off
hardstatus alwayslastline
hardstatus string "%{= Ky}%-Lw%{=r}%20>%n %t%{= Ky}%+Lw %{= Ky}"
termcapinfo xterm*|rxvt*|kterm*|Eterm* 'hs:ts=\E]0;:fs=\007:ds=\E]0;\007'
caption string '%?%F%{=b KW} ***%:%{.Kw} %? %t'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment