Skip to content

Instantly share code, notes, and snippets.

@Perlence
Last active Aug 21, 2016
Embed
What would you like to do?
WScript wrapper around st
/* global WScript */
// Convert WScript.Arguments to Array
var wargs = WScript.Arguments;
var args = [];
var isPathRe = /^[A-Za-z]:\\.*/;
var driveRe = /^([A-Za-z]):/;
for (var i = 0; i < wargs.length; i++) {
var warg = wargs(i);
// Convert Windows path to POSIX path
if (isPathRe.test(warg)) {
warg = warg
// Replace backslash with slash
.replace(/\\/g, '/')
// Replace drive letter with lower case mount dir
.replace(driveRe, function (_, m1) {
return '/mnt/' + m1.toLowerCase();
});
}
// Quote the argument
args.push('"' + warg + '"');
}
var shell = WScript.CreateObject('WScript.Shell');
var windowStyle = 0; // Hide the console window
var waitOnReturn = false;
shell.Run("bash -c 'DISPLAY=:0 st " + args.join(' ') + "'", windowStyle, waitOnReturn);
@abakum

This comment has been minimized.

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