Last active
August 21, 2016 21:35
-
-
Save Perlence/d0a25a9db024249e4baeb21e518454fa to your computer and use it in GitHub Desktop.
WScript wrapper around st
This file contains hidden or 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
/* 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dad's style :)
https://gist.github.com/abakum/a319470cca7e47bb14f621b2226e0fa1