Skip to content

Instantly share code, notes, and snippets.

@clintxs
Last active January 4, 2016 14:39
Show Gist options
  • Save clintxs/8635501 to your computer and use it in GitHub Desktop.
Save clintxs/8635501 to your computer and use it in GitHub Desktop.
My settings for the [Slate](https://github.com/jigish/slate) app. Credit to zdw for [his .slate config](https://gist.github.com/zdw/5355257).
config defaultToCurrentScreen true
config modalEscapeKey esc
# Set a percentage or number of pixels to move the window when using nudge
alias nudge-amount 80
# I map most of my hotkeys to cmd+ctrl+alt, which I have remapped to my
# caps lock key. This is just an easy way to refer to that key.
alias hyper cmd;ctrl;alt
alias modal space,cmd,ctrl,alt:toggle
# Some variables so I can re-orient my monitors without affecting my layouts.
alias mainDisplay 1
alias laptopDisplay 0
# General aliases
alias sox screenOriginX
alias soy screenOriginY
alias ssx screenSizeX
alias hssx screenSizeX/2
alias tssx screenSizeX/3
alias qssx screenSizeX/4
alias fssx screenSizeX/5
alias ssy screenSizeY
alias hssy screenSizeY/2
alias tssy screenSizeY/3
alias qssy screenSizeY/4
alias fssy screenSizeY/5
alias center move screenOriginX+((screenSizeX-windowSizeX)/2);screenOriginY+((screenSizeY-windowSizeY)/2) windowSizeX;windowSizeY
alias maximize move screenOriginX;screenOriginY screenSizeX;screenSizeY
# Aliases for stretching the edge of the window to one side of the screen
alias resize-to-bottom move windowTopLeftX;windowTopLeftY windowSizeX;(screenSizeY-windowTopLeftY)
alias resize-to-top move windowTopLeftX;screenOriginY windowSizeX;(screenSizeY-windowTopLeftY)
alias resize-to-left move window
# Resizes the window to the full screen height, but leaves the width alone
alias full-vertical move windowTopLeftX;screenOriginY windowSizeX;screenSizeY
# Resizes the window to 50% of the screen width, 100% of screen height, and moves it to the center
alias center-half move (screenSizeX-(screenSizeX/2))/2;screenOriginY screenSizeX/2;screenSizeY
alias left-half push left bar-resize:screenSizeX/2
alias right-half push right bar-resize:screenSizeX/2
alias top-half push top bar-resize:screenSizeY/2
alias bottom-half push bottom bar-resize:screenSizeY/2
alias right-third move ${sox}+${ssx}-${tssx};${soy} ${tssx};${ssy}
alias right-quarter move ${sox}+${ssx}-${qssx};${soy} ${qssx};${ssy}
alias center-and-resize move (screenSizeX-(screenSizeX*2/3))/2;(screenSizeY-(screenSizeY*3/4))/2 screenSizeX*2/3;screenSizeY*3/4
# Binds. Woo!
bind 8:${hyper} ${center-and-resize}
bind pad8:${hyper} ${center-and-resize}
bind home:${hyper} relaunch
bind z:${hyper} undo
bind down:${hyper} push bottom
bind up:${hyper} push top
bind left:${hyper} push left
bind right:${hyper} push right
bind -:${hyper} ${center}
bind pad-:${hyper} ${center}
# bind down:${hyper};shift ${resize-to-bottom}
# bind up:${hyper};shift ${resize-to-top}
bind left:${hyper};shift ${left-half}
bind 2:${hyper};shift ${left-half}
bind pad2:${hyper};shift ${left-half}
bind right:${hyper};shift ${right-half}
bind 3:${hyper};shift ${right-half}
bind pad3:${hyper};shift ${right-half}
bind up:${hyper};shift ${top-half}
bind down:${hyper};shift ${bottom-half}
bind 0:${hyper} ${full-vertical}
bind pad0:${hyper} ${full-vertical}
bind 1:${hyper} ${maximize}
bind pad1:${hyper} ${maximize}
# Move the window between monitors
bind 4:${hyper} throw 0
bind pad4:${hyper} throw 0
bind 5:${hyper} throw 1
bind pad5:${hyper} throw 1
### Modal bindings
# Move the window in ${nudge-amount}px increments
bind right:${modal} nudge +${nudge-amount} +0
bind left:${modal} nudge -${nudge-amount} +0
bind up:${modal} nudge +0 -${nudge-amount}
bind down:${modal} nudge +0 +${nudge-amount}
# Resize the window (keeping top left the same)
bind a:${modal} resize -${nudge-amount} +0
bind d:${modal} resize +${nudge-amount} +0
bind s:${modal} resize +0 +${nudge-amount}
bind w:${modal} resize +0 -${nudge-amount}
# Resize the window (keeping bottom right the same)
bind l:${modal} resize -${nudge-amount} +0 bottom-right
bind h:${modal} resize +${nudge-amount} +0 bottom-right
bind k:${modal} resize +0 +${nudge-amount} bottom-right
bind j:${modal} resize +0 -${nudge-amount} bottom-right
# Move the window between monitors
bind 1:${modal} throw 0
bind 2:${modal} throw 1
bind esc:ctrl grid padding:5 0:6,6 1:8,6
layout 2mon 'Safari':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Opera':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Google Chrome':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Google Chrome Canary':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Chromium':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Firefox':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Sublime Text 2':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Preview':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Finder':REPEAT ${maximize} ${mainDisplay}
layout 2mon 'Mail' ${maximize} ${mainDisplay}
layout 2mon 'Pocket' ${maximize} ${mainDisplay}
layout 2mon 'Reeder' ${maximize} ${mainDisplay}
layout 2mon 'Path Finder' ${maximize} ${mainDisplay}
layout 2mon 'iTerm' ${center} ${mainDisplay}
layout 2mon 'Activity Monitor' ${center} ${mainDisplay}
layout 2mon 'VLC' ${maximize} ${laptopDisplay}
layout 2mon 'iTunes' ${maximize} ${laptopDisplay}
layout 2mon 'YoruFukurou' ${right-quarter}
layout 2mon 'Notational Velocity' ${right-quarter}
layout 2mon 'nvALT' ${right-quarter}
default 2mon count:2
layout 1mon 'Safari':REPEAT ${maximize}
layout 1mon 'Opera':REPEAT ${maximize}
layout 1mon 'Google Chrome':REPEAT ${maximize}
layout 1mon 'Google Chrome Canary':REPEAT ${maximize}
layout 1mon 'Chromium':REPEAT ${maximize}
layout 1mon 'Firefox':REPEAT ${maximize}
layout 1mon 'Sublime Text 2':REPEAT ${maximize}
layout 2mon 'Preview':REPEAT ${maximize}
layout 1mon 'Finder':REPEAT ${maximize}
layout 1mon 'Mail' ${maximize}
layout 1mon 'Pocket' ${maximize}
layout 1mon 'Reeder' ${maximize}
layout 1mon 'Path Finder' ${maximize}
layout 1mon 'iTerm' ${center}
layout 1mon 'Activity Monitor' ${center}
layout 1mon 'YoruFukurou' ${right-third}
layout 1mon 'Notational Velocity' ${right-third}
layout 1mon 'nvALT' ${right-third}
layout 1mon 'VLC' ${maximize}
layout 1mon 'iTunes' ${maximize}
default 1mon count:1
// Essentially the goal here is to have our key binding work differently
// depending on whether a window's on my laptop screen or my main display. If
// it's on the laptop display, we break windows up into thirds. If it's on my
// main display there's more room to work with, so I use fourths instead.
//
// This isn't possible to set up in the default .slate file, but the JS bindings
// are expressive enough to accomplish it here.
// Set up our modifier key for key bindings
var hyper = 'cmd;ctrl;alt';
function isLaptop(currentWindow) {
var rect = currentWindow.screen().rect();
return rect.width == 1280 && rect.height == 800;
}
function moveLeft(currentWindow) {
// Move to left two thirds -- adding 1 to width so we don't get a pixel gap between windows
var laptopOp = S.opstr('move screenOriginX;screenOriginY screenSizeX*2/3+1;screenSizeY');
// Move to left three fourths
var desktopOp = S.opstr('push left bar-resize:screenSizeX*0.75');
currentWindow.doOperation(isLaptop(currentWindow) ? laptopOp : desktopOp);
}
function moveRight(currentWindow) {
// Move to right third
var laptopOp = S.opstr('push right bar-resize:screenSizeX/3');
// Move to right fourth
var desktopOp = S.opstr('push right bar-resize:screenSizeX/4');
currentWindow.doOperation(isLaptop(currentWindow) ? laptopOp : desktopOp);
}
S.bind('2:' + hyper, moveLeft);
S.bind('pad2:' + hyper, moveLeft);
S.bind('3:' + hyper, moveRight);
S.bind('pad3:' + hyper, moveRight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment