-
Notifications
You must be signed in to change notification settings - Fork 0
Operations
This page lists all Slate operations.
var move = slate.operation("move", {
"x" : topLeftX,
"y" : topLeftY,
"width" : width,
"height" : height,
"screen" : screen
});
-
topLeftX- top left x coordinate of the window's desired position. can be a String Expression, a Number or a function that returns one of them. -
topLeftY- top left y coordinate of the window's desired position. can be a String Expression, a Number or a function that returns one of them. -
width- width of the window's desired position. can be a string expression, a number or a function that returns one of them. -
height- height of the window's desired position. can be a string expression, a number or a function that returns one of them. -
screen- (optional) the reference to the screen of the window's desired position. If this is not specified, it will default to the screen the window is currently on. Can be a String reference, screen object, or a function that returns a String reference. Check this page for more information about screen objects and screen references.
var move = slate.operation("move", {
"x" : screenOriginX,
"y" : screenOriginY,
"width" : 100,
"height" : 100,
"screen" : "1"
});
slate.bind("pad1:ctrl", move);
Will bind the keystroke ctrl+numpad1 to moving the window to the screen at index 1 with top-left coordinate screenOriginX,screenOriginY and size 100,100
Note: Remember to offset with screenOriginX in your topLeftX and screenOriginY in your topLeftY when using the screen option (or when using multiple screens in general) or your move operation will offset from the default origin (0,0) which is the origin of screen 0.
Global configs only. No Operation specific configs available.
var resize = slate.operation("resize", {
"width" : width,
"height" : height,
"anchor" : anchor
});
-
width- amount to resize width either as a percent or a hard value (e.g."+10%"or"-100"). can be a String or a function that returns a String. -
height- amount to resize height either as a percent or a hard value (e.g."+10%"or"-100"). can be a String or a function that returns a String. -
anchor- (optional) which corner to anchor on. can be a String with one of"top-left","top-right","bottom-left","bottom-right"or a function that returns on of them. default is"top-left".
var resize = slate.operation("resize", {
"width" : "+10%",
"height" : "+0"
});
slate.bind("right:ctrl", move);
Will bind the keystroke ctrl+rightarrow to increase the width the current window by 10% of the current screen size.
Note: ctrl+rightarrow is used by default in Mac OS X by spaces. Be sure to turn these bindings off if you want to use them in Slate.
Global configs and:
resizePercentOf
var push = slate.operation("push", {
"direction" : direction,
"style" : style,
"screen" : screen
});
-
direction- The direction to push the window. can be a String with one of"top","up","bottom","down","left","right"or a function that returns one of them. -
style- (optional) How to push the window. can be a String with one of"none","center","bar","bar-resize:expression"or a function that returns one of them. default is"none". -
screen- (optional) the reference to the screen of the window's desired position. If this is not specified, it will default to the screen the window is currently on. Can be a String reference, screen object, or a function that returns a String reference. Check this page for more information about screen objects and screen references.
var push = slate.operation("push", {
"direction" : "up",
"style" : "bar-resize:screenSizeY/2"
});
slate.bind("up:alt,ctrl", push);
Will bind the keystroke alt-ctrl-uparrow to push the window so that it is aligned with the top of the screen and is resized to form a bar with the height screenSizeY/2
Global configs only. No Operation specific configs available.
var nudge = slate.operation("nudge", {
"x" : x,
"y" : y
});
-
x- amount to nudge x either as a percent or a hard value (e.g."+10%"or"-100"). can be a String or a function that returns a String. -
y- amount to nudge y either as a percent or a hard value (e.g."+10%"or"-100"). can be a String or a function that returns a String.
var nudge = slate.operation("nudge", {
"x" : "-100",
"y" : "+0"
});
slate.bind("left:ctrl,shift", nudge);
Will bind the keystroke ctrl-shift-leftarrow to nudge the window 100 pixels to the left
Global configs and:
nudgePercentOf
Throw the window to any screen's origin: throw screen style
-
screen- the reference to the screen of the window's desired position. If this is not specified, it will default to the screen the window is currently on. Can be a String reference, screen object, or a function that returns a String reference. Check this page for more information about screen objects and screen references. style = (optional) resize|resize:x-expression;y-expression (default will not resize)Example:
bind pad1:alt,ctrl throw 1 resizeWill bind the keystroke alt-ctrl-numpad1 to throw the window to the 2nd screen and resize it to fit that screen
Move/Resize the window into a corner: corner direction style
direction = top-left|top-right|bottom-left|bottom-right
style = (optional) resize:x-expression;y-expression (default will not resize)
-
screen- (optional) the reference to the screen of the window's desired position. If this is not specified, it will default to the screen the window is currently on. Can be a String reference, screen object, or a function that returns a String reference. Check this page for more information about screen objects and screen references.Example:
bind 1:ctrl corner top-left resize:screenSizeX/2;screenSizeY/2Will bind the keystroke ctrl-1 to move the window to the top-left corner and resize it to 1/4 of the screen
Execute a shell command: shell options 'command'
command = (required) the command to run. note that it is a quoted string.
options = (optional) a space separated list of:
wait - block slate until the shell command exits. Useful when using shell commands in a
sequence binding
path: - the inital working directory to use when starting the command. For example
path:~/code would set the inital working directory to ~/code
Example:
bind 1:ctrl wait path:~/code '/opt/local/bin/mvim'
Will bind the keystroke ctrl-1 to run the command `/opt/local/bin/mvim` with the current working directory of `~/code`. Slate will also block until the command is done. Note that you may **not** use the tilda home directory shortcut within the command itself, it is only allowed within the path.
Hide one or more applications: hide applications
applications = a comma separated list of application names. Individual application names must be
surrounded by quotes. You can also specify `current`, `all`, or `all-but:` for the
Application name (no quotes). `current` will apply to the currently focused
application, `all` will apply to all open applications and `all-but:'APP_NAME'` will
apply to all open applications except `APP_NAME`. Note that when trying to hide `all`
it will not work as intended because OS X will not allow every visible app to be
hidden. Hiding `all` will hide all apps but OS X will auto-show one of the apps that
were hidden.
Example:
bind 1:ctrl hide 'iTerm','Google Chrome'
Will bind the keystroke ctrl-1 to hide iTerm and Google Chrome.
Show one or more applications: show applications
applications = a comma separated list of application names. Individual application names must be
surrounded by quotes. You can also specify `current`, `all`, or `all-but:` for the
Application name (no quotes). `current` will apply to the currently focused
application, `all` will apply to all open applications and `all-but:'APP_NAME'` will
apply to all open applications except `APP_NAME`.
Example:
bind 1:ctrl show 'iTerm','Google Chrome'
Will bind the keystroke ctrl-1 to show (unhide) iTerm and Google Chrome.
Toggle one or more applications: toggle applications
applications = a comma separated list of application names. Individual application names must be
surrounded by quotes. You can also specify `current`, `all`, or `all-but:` for the
Application name (no quotes). `current` will apply to the currently focused
application, `all` will apply to all open applications and `all-but:'APP_NAME'` will
apply to all open applications except `APP_NAME`. Note that when trying to toggle `all`
it will may not work as intended because OS X will not allow every visible app to be
hidden. If at any point during the toggling all apps become hidden, OS X will auto-show
one of the apps that were hidden.
Example:
bind 1:ctrl toggle 'iTerm','Google Chrome'
Will bind the keystroke ctrl-1 to toggle iTerm and Google Chrome. Toggle meaning if the individual
application is currently hidden it will be shown and if it is currently shown it will be hidden.
**Note:** If you specify current in this toggle operation it will not toggle properly because after the current application is hidden, it is no longer the current application anymore.
Chain multiple operations to one binding: chain opAndParams1 | opAndParams2 ...
opAndParamsX = any operation string (except sequence, hint and grid)
Example:
bind 1:ctrl chain push up | push right | push down | push left
Will bind the keystroke ctrl-1 to push up on the first press, then push right on the second press, then push down on the third press, the push left on the fourth press and rotate back to pushing up on the fifth press (etc).
Activate a sequence of operations in one binding: sequence opAndParams1 separator opAndParams 2 ...
opAndParamsX = any of the above operation strings (except chain and grid. hint must be last if present)
separator = | or >. | will cause the next operation to be performed on the window focused at the time of
execution of that operation, > will cause the next operation to be performed on the window
focused at the start of the > chain.
Example:
bind 1:ctrl sequence focus right > push left | push right
Will bind the keystroke ctrl-1 to first focus the window to the right, then push the previously focused window to the left, then push the newly focused window to the right. Obviously Hint will ignore `>` and `|` and just display because it doesn't care which window was focused.
Activate a layout: layout name
name = the name of the layout to activate (set using the layout directive)
Example:
bind 1:ctrl layout myLayout
Will bind the keystroke ctrl-l to activate the layout called `myLayout`. Note that the layout **must** be created before you bind it.
Focus a window in a direction or from an application: focus direction|app
direction = right|left|up|above|down|below|behind
app = an app name surrounded by quotes
Example:
bind 1:ctrl focus above
Will bind the keystroke ctrl-1 to focus the window Slate finds to be above the currently focused window (from any application). Minimized and hidden windows are ignored. A couple global configuration options set using the `config` directive exist to tweak this. Also, up and above are the same. Down and below are also the same.
bind 1:ctrl focus 'iTerm'
Will bind the keystroke ctrl-1 to focus the main window of the application iTerm. The main window is the last focused window of that application.
Create a snapshot of your current window locations: snapshot name options
name = the name of the snapshot to create (used in delete-snapshot and activate-snapshot)
options = (optional) a semicolon separated list of any of the following options:
save-to-disk -> saves the snapshot to disk so Slate will load it when it starts up next
stack -> treats this snapshot as stack so you can use this binding multiple times to push snapshots on the stack
Example:
bind 1:ctrl snapshot theName save-to-disk;stack
Will bind the keystroke ctrl-1 to create a snapshot called `theName`, save that snapshot to disk, and treat it as a stack so you can hit the keystroke multiple times to push snapshots onto the stack.
**Note:** There is a menu option to take a snapshot of the current screen configuration.
Delete a snapshot: delete-snapshot name options
name = the name of the snapshot to delete
options = (optional) a semicolon separated list of any of the following options:
all -> if the snapshot is a stack (if it isn't, this option is useless), this will delete all snapshots in the
stack (if this option is not specified, the default is to only delete the top snapshot of the stack).
Example:
bind 1:ctrl delete-snapshot theName all
Will bind the keystroke ctrl-1 to delete the snapshot called `theName` if it exists. This will delete all instances of theName meaning if you have pushed multiple snapshots on the stack, it will completely clear them all.
Activate a snapshot: activate-snapshot name options
name = the name of the snapshot to delete
options = (optional) a semicolon separated list of any of the following options:
delete -> this will delete the snapshot after activating it (if the snapshot is a stack, it will pop the top
snapshot off and keep the rest)
Example:
bind 1:ctrl activate-snapshot theName delete
Will bind the keystroke ctrl-1 to activate the snapshot called `theName` if it exists. This will also delete the snapshot (or pop it off the stack if the snapshot is a stack).
**Note:** There is a menu option to activate the snapshot that you may have created using the menu option.
Show Window Hints (similar to Link Hints in Vimium except for Windows): hint characters
characters = (optional) a simple string of characters to be used for the hints. each hint consists of one
character. if there are more windows than characters then some windows will not get hints.
this string can contain any of the single character Allowed Keys. Letters may be upper case or
lower case, but both will be bound to the lowercase letter for the hint. Using upper or lower
case only changes how they are displayed. The default string of characters is
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Example:
bind 1:ctrl hint QWERTYUIOP
Will bind the keystroke ctrl-1 to show Window Hints using the letters `Q`, `W`, `E`, `R`, `T`, `Y`, `U`, `I`, `O`, and `P`. This will show an overlay in the top-left corner of every window on screen containing one of those letters. While the overlays are showing, if one of those letters is pressed, the corresponding window will be focused. If there are more than 10 windows, some windows will not get hints. Pressing ESC will dismiss the hints.
**Note:** There are *tons* of config options to tweak this.
Show a Grid to one-off resize and move windows: grid options
options is a whitespace separated list of:
padding:<integer> = the padding between cells
screenRef:width,height = width and height are integers specifying the width and height of the grid
(number of cells, not absolute size). screenRef is either the screenID or
screen resolution (widthxheight)
Example:
bind 1:ctrl grid padding:5 1680x1050:16,9 1050x1680:9,16
Will bind the keystroke ctrl-1 to show Grids on each screen. The default width and height are 12. This will set the padding between the cells to be 5. Also, this will change the width and height of the grid on the monitor with the resolution 1680x1050 to 16 and 9 respectively. For the monitor with the resolution 1050x1680, it will set the width to 9 and height to 16. If you have multiple monitors, the Grid that is on the same screen as your mouse pointer will be focused. If you want to use a grid on a different monitor you **must** click it first and then click+drag.
**Note:** There are a bunch of config options to tweak how this looks.
Relaunch Slate: relaunch
Example:
bind 1:ctrl relaunch
Will bind the keystroke ctrl-1 to relaunch Slate. This will also reload the `.slate` file from scratch.
Undo an Operation: undo
Example
bind 1:ctrl undo
Will bind the keystroke ctrl-1 to undo the last binding that was triggered. By default you can undo up to the last 10 commands. This can be changed using the `undoMaxStackSize` config. Also, you can only undo movement-based operations. Focus-related operations will not undo.
[Beta] A Better Application Switcher: switch
If you bind any binding to cmd-tab or cmd-shift-tab, Slate will completely disable the default Mac OS X Application switcher!
Example:
bind tab:cmd switch
Will disable the default Mac OS X Application switcher and bind the keystroke cmd-tab to a better application switcher.
**Note:** There are *tons* of config options to tweak this.