Last active
December 11, 2015 22:39
-
-
Save jewel12/4671136 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// アプリにフォーカスする。アプリが起動していなければ起動する。 | |
var launch_and_focus = function(app_name) { | |
var launch = function(app_names, win) { | |
if( _.any(app_names, function(name){ return name == app_name; }) ) { | |
return; | |
} | |
win.doOperation( | |
slate.operation('shell', { | |
'command' : '/usr/bin/open -a ' + app_name, | |
'waitForExit' : true | |
}) | |
); | |
}; | |
return function(win){ | |
var app_names = []; | |
slate.eachApp(function(app_obj){ app_names.push(app_obj.name()); }); | |
launch(app_names, win); | |
win.doOperation( slate.operation('focus', {'app' : app_name}) ); | |
}; | |
}; | |
var key_binds = {}; | |
key_binds['1:alt'] = launch_and_focus('Google Chrome'); | |
key_binds['2:alt'] = launch_and_focus('iTerm'); | |
key_binds['3:alt'] = launch_and_focus('Emacs'); | |
key_binds['4:alt'] = launch_and_focus('Skype'); | |
key_binds['5:alt'] = launch_and_focus('Things'); | |
slate.bindAll(key_binds); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// oo というアプリにフォーカスしてる時、次は xx というアプリにフォーカスする | |
slate.bind('j:alt', function(win) { | |
var focus_apps = { | |
'iTerm' : 'Emacs', | |
'Emacs' : 'iTerm' | |
}; | |
var app_name = win.app().name(); | |
if (!(app_name in focus_apps)) return; | |
win.doOperation( | |
slate.operation('focus', {'app' : focus_apps[app_name]}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment