Last active
August 4, 2022 02:22
-
-
Save ijortengab/d634290360a017b4b00f344133c0239b to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env php | |
<?php | |
/** | |
* @file | |
* adjust-json-config-windows-terminal-variant-1.php | |
* @author: | |
* IjorTengab <https://ijortengab.id> | |
*/ | |
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') { | |
echo 'Warning: Run this script via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; | |
} | |
if ($_SERVER['argc'] <= 1){ | |
die("Usage:\nphp ".basename(__FILE__)." <file>".PHP_EOL); | |
} | |
if (!file_exists($_SERVER['argv']['1'])){ | |
die("File not found.".PHP_EOL); | |
} | |
function GUID() | |
{ | |
if (function_exists('com_create_guid') === true) | |
{ | |
return trim(com_create_guid(), '{}'); | |
} | |
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535)); | |
} | |
$guid = strtolower(GUID()); | |
$json = json_decode(file_get_contents($_SERVER['argv']['1'])); | |
$cygwin = (object) [ | |
"guid" => "{".$guid."}", | |
"name" => "Cygwin", | |
"commandline" => "c:/cygwin64/bin/bash --login -i", | |
"icon" => "c:/cygwin64/Cygwin.ico", | |
"startingDirectory" => "c:/cygwin64/bin", | |
]; | |
$json->defaultProfile = "{".$guid."}"; | |
$json->profiles->list[] = $cygwin; | |
$json->copyOnSelect = true; | |
$json->multiLinePasteWarning = false; | |
$json->largePasteWarning = false; | |
$json->confirmCloseAllTabs = false; | |
$json->actions[] = (object)[ | |
"command" => "newTab", | |
"keys" => "ctrl+t", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "duplicateTab", | |
"keys" => "ctrl+shift+t", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "newWindow", | |
"keys" => "ctrl+n", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "nextTab", | |
"keys" => "ctrl+pgdn", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "prevTab", | |
"keys" => "ctrl+pgup", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 0, | |
], | |
"keys" => "ctrl+1", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 1, | |
], | |
"keys" => "ctrl+2", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 2, | |
], | |
"keys" => "ctrl+3", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 3, | |
], | |
"keys" => "ctrl+4", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 4, | |
], | |
"keys" => "ctrl+5", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 5, | |
], | |
"keys" => "ctrl+6", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 6, | |
], | |
"keys" => "ctrl+7", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 7, | |
], | |
"keys" => "ctrl+8", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "switchToTab", | |
"index" => 8, | |
], | |
"keys" => "ctrl+9", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "closePane", | |
"keys" => "ctrl+w", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "paste", | |
"keys" => "ctrl+v", | |
]; | |
$json->actions[] = (object)[ | |
"command" => "find", | |
"keys" => "ctrl+f", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "splitPane", | |
"split" => "auto", | |
"splitMode" => "duplicate", | |
], | |
"keys" => "ctrl+d", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "splitPane", | |
"split" => "horizontal" | |
], | |
"keys" => "ctrl+_", | |
]; | |
$json->actions[] = (object)[ | |
"command" => (object)[ | |
"action" => "splitPane", | |
"split" => "vertical" | |
], | |
"keys" => "ctrl+|", | |
]; | |
file_put_contents($_SERVER['argv']['1'],json_encode($json, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment