├── 0001-notify-size-change-inband.patch ├── 0002-add-com-for-lifted-wsl.patch ├── 0012-get-vmid-from-registry.patch ├── LICENSE.mintty ├── LICENSE.wslbridge2 ├── README.md ├── VERSION ├── add default to context menu.lnk ├── add to context menu.lnk ├── appveyor.yml ├── cmd2.bat ├── config-distros.sh ├── configure WSL shortcuts.lnk ├── dequote.bat ├── install-portable.bat ├── install.bat ├── makefile ├── makewinx.cfg ├── mkshortcut.c ├── mkshortcut.vbs ├── remove from context menu.lnk ├── tux.ico ├── tux1.png ├── ubuntu1.png ├── uninstall.bat ├── wsltty home & help.url └── wsltty.png /0001-notify-size-change-inband.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/wslbridge2-backend.cpp b/src/wslbridge2-backend.cpp 2 | index 8b86cc6..63a19e5 100644 3 | --- a/src/wslbridge2-backend.cpp 4 | +++ b/src/wslbridge2-backend.cpp 5 | @@ -17,6 +17,7 @@ 6 | #include 7 | #include 8 | #include 9 | +#include // PIPE_BUF 10 | 11 | #include 12 | #include 13 | @@ -196,6 +197,7 @@ int main(int argc, char *argv[]) 14 | 15 | ssize_t readRet = 0, writeRet = 0; 16 | char data[1024]; /* Buffer to hold raw data from pty */ 17 | + assert(sizeof data <= PIPE_BUF); 18 | 19 | do 20 | { 21 | @@ -206,8 +208,85 @@ int main(int argc, char *argv[]) 22 | if (fds[0].revents & POLLIN) 23 | { 24 | readRet = recv(ioSockets.inputSock, data, sizeof data, 0); 25 | - if (readRet > 0) 26 | - writeRet = write(mfd_dp, data, readRet); 27 | + char * s = data; 28 | + int len = readRet; 29 | + writeRet = 1; 30 | + while (writeRet > 0 && len > 0) 31 | + { 32 | + if (!*s) 33 | + { 34 | + // dispatch NUL escaped inband information 35 | + s++; 36 | + len--; 37 | + 38 | + if (len < 9 && s + 9 >= data + sizeof data) 39 | + { 40 | + // make room for additional loading 41 | + memcpy(data, s, len); 42 | + s = data; 43 | + } 44 | + 45 | + // ensure 1 more byte is loaded to dispatch on 46 | + if (!len) 47 | + { 48 | + readRet = recv(ioSockets.inputSock, s, 1, 0); 49 | + if (readRet > 0) 50 | + { 51 | + len += readRet; 52 | + } 53 | + else 54 | + { 55 | + writeRet = -1; 56 | + break; 57 | + } 58 | + } 59 | + if (*s == 2) 60 | + { 61 | + // STX: escaped NUL 62 | + s++; 63 | + len--; 64 | + writeRet = write(mfd_dp, "", 1); 65 | + } 66 | + else if (*s == 16) 67 | + { 68 | + // DLE: terminal window size change 69 | + s++; 70 | + len--; 71 | + // ensure 8 more bytes are loaded for winsize 72 | + while (readRet > 0 && len < 8) 73 | + { 74 | + readRet = recv(ioSockets.inputSock, s + len, 8 - len, 0); 75 | + if (readRet > 0) 76 | + { 77 | + len += readRet; 78 | + } 79 | + } 80 | + if (readRet <= 0) 81 | + { 82 | + writeRet = -1; 83 | + break; 84 | + } 85 | + struct winsize * winsp = (struct winsize *)s; 86 | + s += 8; 87 | + len -= 8; 88 | + winsp->ws_xpixel = 0; 89 | + winsp->ws_ypixel = 0; 90 | + ret = ioctl(mfd, TIOCSWINSZ, winsp); 91 | + if (ret != 0) 92 | + perror("ioctl(TIOCSWINSZ)"); 93 | + } 94 | + } 95 | + else 96 | + { 97 | + int n = strnlen(s, len); 98 | + writeRet = write(mfd_dp, s, n); 99 | + if (writeRet > 0) 100 | + { 101 | + s += writeRet; 102 | + len -= writeRet; 103 | + } 104 | + } 105 | + } 106 | } 107 | 108 | /* Resize window when buffer received in control socket */ 109 | diff --git a/src/wslbridge2.cpp b/src/wslbridge2.cpp 110 | index 300ad57..3ba9096 100644 111 | --- a/src/wslbridge2.cpp 112 | +++ b/src/wslbridge2.cpp 113 | @@ -43,19 +43,41 @@ union IoSockets 114 | /* global variable */ 115 | static volatile union IoSockets g_ioSockets = { 0 }; 116 | 117 | +#define dont_debug_inband 118 | +#define dont_use_controlsocket 119 | + 120 | static void resize_window(int signum) 121 | { 122 | +#ifdef use_controlsocket 123 | +#warning this may crash for unknown reason, maybe terminate the backend 124 | struct winsize winp; 125 | + ioctl(STDIN_FILENO, TIOCGWINSZ, &winp); 126 | 127 | /* Send terminal window size to control socket */ 128 | - ioctl(STDIN_FILENO, TIOCGWINSZ, &winp); 129 | send(g_ioSockets.controlSock, (char *)&winp, sizeof winp, 0); 130 | +#else 131 | + static char wins[2 + sizeof(struct winsize)] = {0, 16}; 132 | + static struct winsize * winsp = (struct winsize *)&wins[2]; 133 | + ioctl(STDIN_FILENO, TIOCGWINSZ, winsp); 134 | + 135 | +#ifdef debug_inband 136 | + /* Send terminal window size inband, visualized as ESC sequence */ 137 | + char resizesc[55]; 138 | + //sprintf(resizesc, "\e_8;%u;%u\a", winsp->ws_row, winsp->ws_col); 139 | + sprintf(resizesc, "^[_8;%u;%u^G", winsp->ws_row, winsp->ws_col); 140 | + send(g_ioSockets.inputSock, resizesc, strlen(resizesc), 0); 141 | +#else 142 | + /* Send terminal window size inband, with NUL escape */ 143 | + send(g_ioSockets.inputSock, wins, sizeof wins, 0); 144 | +#endif 145 | +#endif 146 | } 147 | 148 | static void* send_buffer(void *param) 149 | { 150 | int ret; 151 | char data[1024]; 152 | + assert(sizeof data <= PIPE_BUF); 153 | 154 | while (1) 155 | { 156 | @@ -65,8 +87,33 @@ static void* send_buffer(void *param) 157 | closesocket(g_ioSockets.inputSock); 158 | break; 159 | } 160 | - if (!send(g_ioSockets.inputSock, data, ret, 0)) 161 | - break; 162 | + char * s = data; 163 | + int len = ret; 164 | + while (ret > 0 && len > 0) 165 | + { 166 | + if (!*s) 167 | + { 168 | + // send NUL STX 169 | +#ifdef debug_inband 170 | + ret = send(g_ioSockets.inputSock, (void*)"nul", 3, 0); 171 | +#else 172 | + static char NUL_STX[] = {0, 2}; 173 | + ret = send(g_ioSockets.inputSock, NUL_STX, 2, 0); 174 | +#endif 175 | + s++; 176 | + len--; 177 | + } 178 | + else 179 | + { 180 | + int n = strnlen(s, len); 181 | + ret = send(g_ioSockets.inputSock, s, n, 0); 182 | + if (ret > 0) 183 | + { 184 | + s += ret; 185 | + len -= ret; 186 | + } 187 | + } 188 | + } 189 | } 190 | 191 | pthread_exit(&ret); 192 | @@ -480,16 +527,6 @@ int main(int argc, char *argv[]) 193 | g_ioSockets.controlSock = win_local_accept(controlSock); 194 | } 195 | 196 | - /* Capture window resize signal and send buffer to control socket */ 197 | - { 198 | - struct sigaction act; 199 | - memset(&act, 0, sizeof act); 200 | - act.sa_handler = resize_window; 201 | - act.sa_flags = SA_RESTART; 202 | - ret = sigaction(SIGWINCH, &act, NULL); 203 | - assert(ret == 0); 204 | - } 205 | - 206 | /* Create thread to send input buffer to input socket */ 207 | pthread_t tidInput; 208 | ret = pthread_create(&tidInput, nullptr, send_buffer, nullptr); 209 | @@ -502,6 +539,17 @@ int main(int argc, char *argv[]) 210 | 211 | termState.enterRawMode(); 212 | 213 | + /* Create thread to send window size through control socket */ 214 | + struct sigaction act = {}; 215 | + act.sa_handler = resize_window; 216 | + act.sa_flags = SA_RESTART; 217 | + ret = sigaction(SIGWINCH, &act, NULL); 218 | + assert(ret == 0); 219 | + 220 | + /* Notify initial size in case it's changed since starting */ 221 | + //resize_window(0); 222 | + kill(getpid(), SIGWINCH); 223 | + 224 | /* 225 | * wsltty#254: WORKAROUND: Terminates input thread forcefully 226 | * when output thread exits. Need some inter-thread syncing. 227 | -------------------------------------------------------------------------------- /0002-add-com-for-lifted-wsl.patch: -------------------------------------------------------------------------------- 1 | diff -rup src/sav/GetVmId.cpp src/GetVmId.cpp 2 | --- src/sav/GetVmId.cpp 2021-04-27 13:50:51.000000000 +0000 3 | +++ src/GetVmId.cpp 2022-02-03 19:43:53.684999800 +0000 4 | @@ -46,11 +46,24 @@ void ComInit(void) 5 | EOAC_STATIC_CLOAKING, NULL); 6 | assert(hRes == 0); 7 | 8 | - hRes = CoCreateInstance(CLSID_LxssUserSession, 9 | + // First try with COM server in lifted WSL service 10 | + hRes = CoCreateInstance(CLSID_WslService, 11 | NULL, 12 | CLSCTX_LOCAL_SERVER, 13 | - IID_ILxssUserSession, 14 | + IID_IWSLService, 15 | (PVOID *)&wslSession); 16 | + 17 | + 18 | + // Now try with COM server in system WSL service 19 | + if (FAILED(hRes)) 20 | + { 21 | + hRes = CoCreateInstance(CLSID_LxssUserSession, 22 | + NULL, 23 | + CLSCTX_LOCAL_SERVER, 24 | + IID_ILxssUserSession, 25 | + (PVOID *)&wslSession); 26 | + } 27 | + 28 | assert(hRes == 0); 29 | } 30 | 31 | diff -rup src/sav/LxssUserSession.hpp src/LxssUserSession.hpp 32 | --- src/sav/LxssUserSession.hpp 2021-04-27 13:50:51.000000000 +0000 33 | +++ src/LxssUserSession.hpp 2022-02-03 19:45:22.846298200 +0000 34 | @@ -11,14 +11,26 @@ 35 | #ifndef LXSSUSERSESSION_H 36 | #define LXSSUSERSESSION_H 37 | 38 | -/* Class identifier */ 39 | +// COM IDs for lifted WSL service 40 | +static const GUID CLSID_WslService = { 41 | + 0xF122531F, 42 | + 0x326B, 43 | + 0x4514, 44 | + { 0x85, 0xAE, 0xDC, 0x99, 0xD3, 0x1D, 0x82, 0x56 } }; 45 | + 46 | +static const GUID IID_IWSLService = { 47 | + 0x50047071, 48 | + 0x122C, 49 | + 0x4CAD, 50 | + { 0x9C, 0x93, 0x94, 0x72, 0x0E, 0xB7, 0x7B, 0x06 } }; 51 | + 52 | +// COM IDs for system WSL service 53 | static const GUID CLSID_LxssUserSession = { 54 | 0x4F476546, 55 | 0xB412, 56 | 0x4579, 57 | { 0xB6, 0x4C, 0x12, 0x3D, 0xF3, 0x31, 0xE3, 0xD6 } }; 58 | 59 | -/* Interface identifier */ 60 | static const GUID IID_ILxssUserSession = { 61 | 0x536A6BCF, 62 | 0xFE04, 63 | -------------------------------------------------------------------------------- /0012-get-vmid-from-registry.patch: -------------------------------------------------------------------------------- 1 | --- wslbridge2/src/wslbridge2.cpp 2024-10-10 20:20:21.931891800 +0000 2 | +++ wslbridge2-0.12/src/wslbridge2.cpp 2024-10-08 09:31:35.954145800 +0000 3 | @@ -228,6 +228,26 @@ static void start_dummy(std::wstring wsl 4 | CloseHandle(pi.hThread); 5 | } 6 | 7 | +bool GetIdFromRegistry(GUID *guid) { 8 | + HKEY hKeyRoot = HKEY_LOCAL_MACHINE; 9 | + std::wstring subKey = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\HostComputeService\\VolatileStore\\ComputeSystem"; 10 | + HKEY hKey; 11 | + if (RegOpenKeyEx(hKeyRoot, subKey.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS) { 12 | + DWORD index = 0; 13 | + WCHAR keyName[256]; 14 | + DWORD keyNameSize = sizeof(keyName) / sizeof(keyName[0]); 15 | + 16 | + while (RegEnumKeyEx(hKey, index, keyName, &keyNameSize, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) { 17 | + RegCloseKey(hKey); 18 | + std::wstring id = L"{" + std::wstring(keyName) + L"}"; 19 | + return IIDFromString(id.c_str(), guid) == S_OK; 20 | + } 21 | + RegCloseKey(hKey); 22 | + } 23 | + return false; 24 | +} 25 | + 26 | + 27 | int main(int argc, char *argv[]) 28 | { 29 | /* Minimum requirement Windows 10 build 17763 aka. version 1809 */ 30 | @@ -387,8 +407,8 @@ int main(int argc, char *argv[]) 31 | if (LiftedWSLVersion) 32 | start_dummy(wslPath, wslCmdLine, distroName, debugMode); 33 | 34 | - const HRESULT hRes = GetVmId(&DistroId, &VmId, LiftedWSLVersion); 35 | - if (hRes != 0) 36 | + const bool hRes = GetIdFromRegistry(&VmId); 37 | + if (!hRes) 38 | fatal("GetVmId: %s\n", GetErrorMessage(hRes).c_str()); 39 | 40 | inputSock = win_vsock_create(); 41 | -------------------------------------------------------------------------------- /LICENSE.mintty: -------------------------------------------------------------------------------- 1 | mintty is copyright 2008-23 Andy Koppe, 2015-23 Thomas Wolff. 2 | 3 | Licensed under the terms of the GNU General Public License version 3 or later, 4 | amended with the bundling clause to clarify ambiguous interpretation. 5 | 6 | The bundling clause can be found in the accompanying file LICENSE.bundling. 7 | 8 | The GPL license text can be found in the accompanying file LICENSE.GPL, 9 | at /usr/share/doc/common-licenses/GPL-3.0 on Cygwin installs, 10 | or on the GNU website at http://www.gnu.org/licenses/gpl.html. 11 | 12 | Sources are available from the project page at http://mintty.github.io/. 13 | 14 | Based on PuTTY version 0.60 by Simon Tatham and contributors. 15 | Big thanks to everyone involved for their work on PuTTY. 16 | See LICENSE.PuTTY for PuTTY's copyright notice, contributors, and license. 17 | The sources of PuTTY 0.60 can be downloaded from 18 | ftp://ftp.chiark.greenend.org.uk/users/sgtatham/putty-0.60. 19 | 20 | The minibidi algorithm is under MIT license as quoted in the source file. 21 | 22 | Sixel code (sixel.c) is relicensed under GPL like mintty with the 23 | permission of its author (kmiya@culti); Sixel colour conversion code 24 | (sixel_hls.c) is licensed by its author Ross Combs under the license 25 | quoted in the source file. 26 | 27 | The program icon is the apps/utilities-terminal icon from KDE's Oxygen theme, 28 | retrieved from http://websvn.kde.org/trunk/KDE/kdebase/runtime/pics/oxygen. 29 | Thanks to the KDE artists for their sleek design. The Oxygen icons are licensed 30 | under the terms of the LGPLv3; see LICENSE.Oxygen for details. 31 | 32 | The colour schemes / theme files bundled with mintty are included 33 | under various licenses. The source and license or permission are 34 | quoted in the respective theme files. 35 | 36 | Bell sounds files are included, mostly under the creative commons license 37 | (https://creativecommons.org/publicdomain/zero/1.0/), see also the README 38 | in the sounds subdirectory. 39 | 40 | -------------------------------------------------------------------------------- /LICENSE.wslbridge2: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mintty as a terminal for WSL (Windows Subsystem for Linux). 2 | 3 | 4 | 5 | ### Overview ### 6 | 7 | WSLtty components 8 | * wsltty package components (see below) in the user’s local application folder 9 | `%LOCALAPPDATA%` 10 | * a wsltty configuration directory in the user’s application folder `%APPDATA%` 11 | (“home”-located configuration files from a previously installed version 12 | will be migrated to the new default location) 13 | * Start Menu shortcuts to start WSL terminals 14 | * Desktop shorcut to start a terminal for the default WSL distribution 15 | * `*.bat` scripts to invoke WSL terminals from the command line 16 | * optional context menu entries for Windows Explorer to start WSL terminals in the respective folder 17 | * install/uninstall context menu items from Start Menu subfolder `WSLtty` 18 | 19 | --- 20 | 21 | ### Requirements ### 22 | 23 | To connect to WSL, wsltty uses wslbridge2, which uses undocumented 24 | Windows APIs that have been changed various times, so wslbridge2 needed 25 | to catch up with incompatible changes, particularly to support WSL V2. 26 | (See e.g. issue #343; to work with WSL V2, wsltty 2.0.0 needed a WSL update 27 | to [release 1.3.17](https://github.com/microsoft/WSL/releases/tag/1.3.17).) 28 | 29 | Since release 3.0.5, WSLtty requires Windows version 1809 (the November 2018 release). 30 | 31 | By end of 2024, wsltty works again with recent updates of the WSL subsystem. 32 | 33 | --- 34 | 35 | ### Installation from this repository ### 36 | 37 | #### WSLtty installer ([Download](https://github.com/mintty/wsltty/releases) standalone installation) #### 38 | 39 | From the [release downloads](https://github.com/mintty/wsltty/releases), 40 | run the wsltty-VERSION-x86_64-install.exe installer to install 41 | the components listed above. Make sure to select a 64-bit installer 42 | on a 64-bit system. 43 | If Windows complains with a “Windows protected your PC” popup, 44 | you may need to click “Run anyway” to proceed with the installation. 45 | You may need to open the Properties of the installer first, tab “General” 46 | section “Security” (if available) and select “Unblock”, 47 | to enable the “Run anyway” button. 48 | 49 | #### WSLtty Portable installer 50 | 51 | For a portable installation, e.g. on a USB stick, choose the 52 | “-install-portable.exe” file for download. Installation will prompt 53 | for a portable installation folder interactively. 54 | For example, choosing `U:\opt` will create and use folder 55 | `U:\opt\wsltty` both as installation directory and configuration directory. 56 | Portable installation does not install any start menu or desktop shortcuts 57 | and no context menu entries. It creates a shortcut in the selected 58 | portable installation folder to start the default WSL distribution. 59 | 60 | Note: For an update installation, either the parent directory or the target 61 | directory itself can be selected. 62 | 63 | Note: If you rename or move the installation directory, the icon of the 64 | “WSL Terminal Portable” shortcut will not work anymore; re-run the 65 | install-portable.bat script in the installation folder to refresh it. 66 | 67 | #### Installation from archive #### 68 | 69 | In case a local anti-virus guard barfs about the wsltty installer, the 70 | release also contains a `.cab` file. Download it, open it, extract its files 71 | to some temporary deployment directory, and invoke `install.bat` from there, 72 | or `install-portable.bat` for a portable installation. 73 | 74 | #### Quiet installer #### 75 | 76 | The wsltty-VERSION-x86_64-install-quiet.exe installer is intended for 77 | integration in another installation framework. 78 | 79 | #### Installation from source repository #### 80 | 81 | Checkout the wsltty repository, or download the source archive, unpack and rename the directory to `wsltty`. 82 | Install Alpine WSL from the Microsoft Store. 83 | Invoke `make build`, then `make install`. 84 | 85 | Note this has to be done within a Cygwin environment. A minimal Cygwin 86 | environment for this purpose would be installed with the 87 | [Cygwin installer](https://cygwin.com/setup-x86_64.exe) 88 | from [cygwin.com](https://cygwin.com/), 89 | with additional packages `make`, `gcc-g++`, `unzip`, `zoo`, `patch`, (`lcab`). 90 | 91 | #### Build installers #### 92 | 93 | Install a minimal Cygwin environment plus the additional packages as 94 | listed for «Installation from source repository». 95 | Invoke `make pkg` or just `make`. 96 | 97 | #### Installation to non-default locations #### 98 | 99 | (For experts) 100 | Within the installation process, provide parameters to the script `install.bat`. 101 | The optional first parameter designates the installation target, 102 | the optional second parameter designates the configuration directory. 103 | 104 | ### Installation with other package management environments ### 105 | 106 | Note: These are 3rd-party packages, not managed by this repository. 107 | 108 | #### Windows Package Manager #### 109 | 110 | ([Check package](https://github.com/microsoft/winget-pkgs/tree/master/manifests/m/Mintty/WSLtty)) 111 | To install wsltty from the 112 | [Windows Package Manager Community Repository](https://github.com/microsoft/winget-pkgs), 113 | invoke one of 114 | * `winget install wsltty` 115 | * `winget upgrade wsltty` 116 | 117 | #### Chocolatey #### 118 | 119 | ([Check package](https://community.chocolatey.org/packages/wsltty)) 120 | If you use the [Chocolatey package manager](https://chocolatey.org/), 121 | invoke one of 122 | * `choco install wsltty` 123 | * `choco upgrade wsltty` 124 | 125 | #### Scoop #### 126 | 127 | ([Check package](https://scoop.sh/#/apps?q=wsltty)) 128 | If you use the [Scoop package manager](https://scoop.sh/), 129 | * `scoop bucket add extras` 130 | 131 | then, invoke one of 132 | * `scoop install wsltty` 133 | * `scoop update wsltty` 134 | 135 | ### Uninstallation ### 136 | 137 | To uninstall wsltty desktop, start menu, and context menu integration: 138 | Open a Windows `cmd`, go into the wsltty installation folder: 139 | `cd %LOCALAPPDATA%\wsltty` and run the `uninstall` script. 140 | To uninstall wsltty software completely, remove the installation folder manually. 141 | 142 | --- 143 | 144 | ### Invocation ### 145 | 146 | WSLtty can be invoked with 147 | * installed Start Menu shortcuts (or Desktop shortcuts if copied there) 148 | * *.bat scripts (optionally with WSL command as parameters) (see [Command line scripts](#command-line-scripts-wslbat) below) 149 | * Explorer context menu (if installed from the Start Menu `WSLtty` subfolder) 150 | 151 | Starting the mintty terminal directly from the WSLtty installation location 152 | is discouraged because that would bypass essential options. 153 | 154 | #### WSL V2 #### 155 | 156 | Terminal communication with WSL via its modes V1 or V2 is handled 157 | automatically by wsltty (mintty and the wslbridge2 gateway). 158 | 159 | #### Starting issues #### 160 | 161 | If wsltty fails with an 162 | `Error: Could not fork child process: Resource temporarily unavailable`..., 163 | its runtime may be affected by some over-ambitious virus defense strategy. 164 | For example, with Windows Defender, option “Force randomization for images” 165 | should be disabled. 166 | 167 | If wsltty fails with an error message that mentions a disk mount path (e.g. `/mnt/c`), 168 | workarounds may be the shutdown of the WSL V2 virtual machine (`wsl --shutdown` on the distro) 169 | or turning off “fast startup” in the Windows power settings (#246, #248). 170 | 171 | #### WSL shell starting issues #### 172 | 173 | With WSL V2, an additional background shell is run which may cause trouble 174 | for example when setting up automatic interaction between Windows side and 175 | WSL side 176 | (see https://github.com/mintty/wsltty/issues/197#issuecomment-687030527). 177 | As a workaround, the following may be added to (the beginning of) the 178 | WSL shell initialization script `.bashrc` (adapt for other shells): 179 | ``` 180 | # work around https://github.com/mintty/wsltty/issues/197 181 | if [[ -n "$WSL_DISTRO_NAME" ]]; then 182 | command -v cmd.exe > /dev/null || exit 183 | fi 184 | ``` 185 | 186 | --- 187 | 188 | ### Configuration ### 189 | 190 | #### Start Menu and Desktop shortcuts #### 191 | 192 | In the Start Menu, the following shortcuts are installed: 193 | * Shortcut `WSL Terminal` to start the default WSL distribution (as configured with the Windows tool `wslconfig` or `wsl -s`) 194 | * For each installed WSL distribution, for example `Ubuntu`, a shortcut like `Ubuntu Terminal` to start in the WSL user home 195 | 196 | In the Start Menu subfolder WSLtty, the following additional shortcuts are installed: 197 | * Shortcut `WSL Terminal %` to start the default WSL distribution in the Windows %USERPROFILE% home 198 | * For each installed WSL distribution, for example `Ubuntu`, a shortcut like `Ubuntu Terminal %` to start in the Windows %USERPROFILE% home 199 | 200 | One Desktop shortcut is installed: 201 | * Shortcut `WSL Terminal` to start the default WSL distribution (as configured with the Windows tool `wslconfig` or `wsl -s`) 202 | 203 | Other, distribution-specific shortcuts can be copied to the desktop 204 | from the Start Menu if desired. 205 | 206 | The Start menu folder WSLtty contains the link 207 | `configure WSL shortcuts`. 208 | This function is initially run when wsltty is installed. 209 | It should be rerun after adding or removing WSL distributions, 210 | in order to create the respective set of shortcuts in the Start menu. 211 | 212 | #### Command line scripts `wsl*.bat` #### 213 | 214 | WSLtty installs the following scripts into `%LOCALAPPDATA%\Microsoft\WindowsApps` 215 | (and a copy in its application folder `%LOCALAPPDATA%\wsltty`): 216 | 217 | * For each installed WSL distribution, e.g. Ubuntu, a command script like `Ubuntu.bat` to start in the current folder/directory 218 | * For each installed WSL distribution, e.g. Ubuntu, a command script like `Ubuntu~.bat` to start in the WSL user home 219 | * `WSL.bat` and `WSL~.bat` to start the default WSL distribution 220 | 221 | The scripts accept an optional invocation command (since 3.7.8). 222 | 223 | Given that `%LOCALAPPDATA%\Microsoft\WindowsApps` is in your PATH, 224 | the scripts can be invoked from cmd.exe, PowerShell, or via WIN+R. 225 | 226 | #### Context menu entries #### 227 | 228 | WSLtty provides context menu entries for all installed WSL distributions 229 | and one for the configured default distribution, 230 | to start a respective WSL terminal in a specific folder from an Explorer window. 231 | They are not installed by default. 232 | 233 | To add launch entries for the default or all WSL distributions to the 234 | Explorer context menu, or remove them, run the respective script from the 235 | Start Menu subfolder `WSLtty`: 236 | * `add default to context menu` 237 | adds context menu entries for the default WSL distribution 238 | * `add to context menu` 239 | adds context menu entries for all WSL distributions 240 | * `remove from context menu` 241 | removes context menu entries for WSL distributions 242 | 243 | #### Icon #### 244 | 245 | Wsltty installation and the mintty terminal try to use the icon of the 246 | respective WSL distribution. If it cannot be determined, a penguin icon 247 | is used as a fallback. You can replace it with your preferred default icon 248 | by replacing the icon file `%LOCALAPPDATA%\wsltty\wsl.ico`. 249 | 250 | #### Mintty settings #### 251 | 252 | Mintty can maintain its configuration file in various locations, 253 | with the following precedence: 254 | * file given with mintty option `-c` (not used by wsltty default installation) 255 | * file `config` in directory given with mintty option `--configdir` 256 | * **`%APPDATA%\wsltty\config`** in the default wsltty installation 257 | * `%HOME%\.minttyrc` (usage deprecated with wsltty) 258 | * `%HOME%\.config\mintty\config` (usage deprecated with wsltty) 259 | * common config file for all mintty installation instances 260 | * **`%APPDATA%\mintty\config`** 261 | * `%LOCALAPPDATA%\wsltty\etc\minttyrc` (usage deprecated with wsltty) 262 | 263 | Note: 264 | * `%APPDATA%\wsltty\config` is the user configuration file location. 265 | Further subdirectories of `%APPDATA%\wsltty` are used for language, 266 | themes, and sounds resource configuration. 267 | Note the distinction from `%LOCALAPPDATA%\wsltty` which is the default 268 | wsltty software installation location. 269 | * The `%APPDATA%\mintty\config` option provides the possibility to 270 | maintain common mintty settings for various installations (like 271 | wsltty, Cygwin, MinGW/msys, Git for Windows, MinEd for Windows). 272 | * (About deprecated options) By default, `%HOME%` would refer to the 273 | root directory of the cygwin standalone installation hosting wsltty. 274 | So `%HOME%` would mean `%LOCALAPPDATA%\wsltty\home\%USERNAME%`. 275 | If you define `HOME` at Windows level, this changes accordingly. 276 | Note, however, that the WSL `$HOME` is a completely different setting. 277 | 278 | #### Emoji deployment #### 279 | 280 | Mintty and the wsltty package do not bundle actual emoji graphics but 281 | there are scripts to support easy download and deployment. 282 | If you have another instance of mintty installed (e.g. in cygwin) 283 | and have emojis deployed already in the common config folder 284 | `%APPDATA%\mintty\emojis`, they will be reused by wsltty. 285 | 286 | To deploy emojis standalone for wsltty, use the scripts installed in 287 | `%APPDATA%\wsltty\emojis` within WSL: 288 | * `cd $(wslpath "$APPDATA/wsltty/emojis")` 289 | * `getemojis` to provide emoji graphics as listed by Unicode.org 290 | * `getflags` to provide emoji flag graphics (extending Unicode dynamically) from various sources 291 | 292 | #### Shell selection and Login shell #### 293 | 294 | The WSLtty deployment does not impose a shell preference; 295 | it invokes the user’s default shell in login mode by the final `-` parameter: 296 | * `%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" -` 297 | 298 | You may tweak shortcuts, scripts, or context menu entries as follows: 299 | 300 | To launch a default shell in non-login mode, remove the final dash. 301 | 302 | To invoke your preferred shell, replace the final dash with 303 | a shell pathname and an optional `-l` parameter 304 | * `%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= --configdir="%APPDATA%\wsltty" /bin/bash -l` 305 | 306 | --- 307 | 308 | ### WSL locale setup and character encoding ### 309 | 310 | Character encoding setup by locale setting is propagated from the terminal 311 | towards WSL. So you can select your favourite locale with configuration 312 | options or with command-line options, for example in a copied dedicated 313 | desktop shortcut. 314 | 315 | If for example you wish to run WSL in GB18030 encoding, you may set options 316 | `Locale=zh_CN` and `Charset=GB18030` and the WSL shell will adopt that 317 | setting, provided that the selected locale is configured to be available 318 | in the locale database of the WSL distribution. 319 | This can be achieved in Ubuntu with the following commands: 320 | * `sudo mkdir -p /var/lib/locales/supported.d` 321 | * `sudo echo zh_CN.GB18030 GB18030 >> /var/lib/locales/supported.d/local` 322 | * `sudo locale-gen` 323 | 324 | --- 325 | 326 | ### Components and Credits ### 327 | 328 | For mintty, see the [Mintty homepage](http://mintty.github.io/) 329 | (with further screenshots), 330 | the [Mintty manual page](http://mintty.github.io/mintty.1.html), 331 |
and the [Mintty Wiki](https://github.com/mintty/mintty/wiki), 332 | including a [Hints and Tips page](https://github.com/mintty/mintty/wiki/Tips). 333 | 334 | It is based on [Cygwin](http://cygwin.com) 335 | and includes its runtime library ([sources](http://mirrors.dotsrc.org/cygwin/x86/release/cygwin)). 336 | 337 | For interacting with WSL, [wslbridge](https://github.com/rprichard/wslbridge) 338 | used to be the gateway prototype. 339 | Many thanks for this enabling gateway go to Ryan Prichard. 340 | 341 | For recent changes in WSL, particularly WSL mode V2, the new gateway 342 | [wslbridge2](https://github.com/Biswa96/wslbridge2) is used instead. 343 | Many thanks for this further development and maintenance go to Biswapriyo Nath. 344 | 345 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.7.8 2 | -------------------------------------------------------------------------------- /add default to context menu.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/add default to context menu.lnk -------------------------------------------------------------------------------- /add to context menu.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/add to context menu.lnk -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # This file is part of wsltty project 2 | 3 | # Build image; of course wsltty has nothing to do with Visual Studio - 4 | # this is just the name of Appveyor's build environment image 5 | # that also contains cygwin 6 | image: Visual Studio 2022 7 | 8 | # Version format 9 | version: "#{build}" 10 | 11 | # Do not increment build number after pull requests 12 | pull_requests: 13 | do_not_increment_build_number: true 14 | 15 | # Do not start a new build when a new Git tag is created 16 | skip_tags: true 17 | 18 | init: 19 | - cmd: | 20 | set PATH=C:\cygwin64;C:\cygwin64\bin;%windir%\System32 21 | setup-x86_64 -q -P unzip -P zoo -P patch -P lcab 22 | winget install Alpine 23 | 24 | build_script: 25 | - cmd: | 26 | make 27 | 28 | test_script: 29 | - cmd: | 30 | bin\mintty.exe --log mintty.log --exec echo hello mintty 31 | grep echo mintty.log 32 | -------------------------------------------------------------------------------- /cmd2.bat: -------------------------------------------------------------------------------- 1 | %1 "%from%" "%to%" 2 | -------------------------------------------------------------------------------- /config-distros.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # dash built-in echo enforces interpretation of \t etc 4 | echoc () { 5 | #cmd /c echo $* 6 | printf '%s\n' "$*" 7 | } 8 | 9 | copy () { 10 | from="$1" 11 | to="$2" 12 | export from to 13 | cmd /c cmd2.bat copy 14 | } 15 | 16 | delete () { 17 | from="$1" 18 | to="$1" # same again, to fill parameter 19 | export from to 20 | cmd /c cmd2.bat del/F 21 | } 22 | 23 | compare () { 24 | from="$1" 25 | to="$2" 26 | export from to 27 | cmd /c cmd2.bat comp/M 28 | } 29 | 30 | 31 | case "$installdir" in 32 | ?*) custominst=true;; 33 | "") custominst=false;; 34 | esac 35 | 36 | INSTDIR="${installdir:-$LOCALAPPDATA/wsltty}" 37 | echoc "Installing wsltty into $INSTDIR" 38 | INSTDIR=`cd "$INSTDIR"; pwd` 39 | installcop=${installdir:-"$LOCALAPPDATA\\wsltty"} 40 | installdir=${installdir:-'%LOCALAPPDATA%\wsltty'} 41 | 42 | target="$installdir"'\bin\mintty.exe' 43 | case "$INSTDIR" in 44 | */) TARGETPATH="$INSTDIR"bin/mintty.exe;; 45 | *) TARGETPATH="$INSTDIR"/bin/mintty.exe;; 46 | esac 47 | 48 | CONFDIR="${configdir:-$APPDATA/wsltty}" 49 | configdir=${configdir:-'%APPDATA%\wsltty'} 50 | 51 | PATH=/bin:"$PATH":$SYSTEMROOT/System32 52 | 53 | contextmenu=false 54 | remove=false 55 | alldistros=true 56 | config=true 57 | 58 | case "/$0" in 59 | */wsl*) 60 | config=false;; 61 | esac 62 | 63 | case "$1" in 64 | -info) 65 | config=false 66 | shift;; 67 | -shortcuts) 68 | shift;; 69 | -shortcuts-remove) 70 | remove=true 71 | shift;; 72 | -default) 73 | alldistros=false 74 | shift;; 75 | -contextmenu) 76 | contextmenu=true 77 | shift;; 78 | -contextmenu-default) 79 | contextmenu=true 80 | alldistros=false 81 | shift;; 82 | -contextmenu-remove) 83 | contextmenu=true 84 | remove=true 85 | direckey='/HKEY_CURRENT_USER/Software/Classes/Directory' 86 | 87 | regtool list "$direckey/shell" 2>/dev/null | 88 | while read name 89 | do 90 | case `regtool get "$direckey/shell/$name/command/"` in 91 | *bin\\mintty.exe*/bin/wslbridge*|*bin\\mintty.exe*--WSL*) 92 | regtool remove "$direckey/shell/$name/command" 93 | regtool remove "$direckey/shell/$name" 94 | ;; 95 | esac 96 | done 97 | 98 | regtool list "$direckey/Background/shell" 2>/dev/null | 99 | while read name 100 | do 101 | case `regtool get "$direckey/Background/shell/$name/command/"` in 102 | *bin\\mintty.exe*/bin/wslbridge*|*bin\\mintty.exe*--WSL*) 103 | regtool remove "$direckey/Background/shell/$name/command" 104 | regtool remove "$direckey/Background/shell/$name" 105 | ;; 106 | esac 107 | done 108 | exit 109 | shift;; 110 | esac 111 | 112 | 113 | if $config && ! $contextmenu 114 | then 115 | # remove shortcut entries in Start menu and cmd-line bat shortcuts 116 | (cd "$INSTDIR" 117 | for lnk in *.lnk 118 | do 119 | if compare "$lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\$lnk" 120 | then delete "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\$lnk" 121 | fi 122 | done 123 | for bat in *.bat 124 | do 125 | if compare "$bat" "$LOCALAPPDATA\\Microsoft\\WindowsApps\\$bat" 126 | then delete "$LOCALAPPDATA\\Microsoft\\WindowsApps\\$bat" 127 | fi 128 | done 129 | ) 130 | fi 131 | 132 | # test w/o WSL: call this script with REGTOOLFAKE=true dash config-distros.sh 133 | if ${REGTOOLFAKE:-false} 134 | then 135 | regtool () { 136 | case "$1" in 137 | -*) shift;; 138 | esac 139 | key=`echo $2 | sed -e 's,.*{\(.*\)}.*,\1,' -e t -e d` 140 | case "$1.$2" in 141 | list.*) 142 | if $contextmenu 143 | then echo "{0}" 144 | else echo "{1}"; echo "{2}" 145 | fi;; 146 | get.*/DistributionName) 147 | echo "distro$key";; 148 | get.*/BasePath) 149 | echo "C:\\Program\\{$key}\\State";; 150 | get.*/PackageFamilyName) 151 | echo "distro{$key}";; 152 | get.*/PackageFullName) 153 | echo "C:\\Program\\{$key}";; 154 | esac 155 | } 156 | fi 157 | 158 | mkbat () { 159 | echo Creating "$1.bat" 160 | while read line; do echo "$line"; done <<-\/EOB > "$1".bat 161 | @echo off 162 | rem Start mintty terminal for WSL 163 | 164 | rem get basename of this script file, 165 | rem use it to select WSL distribution and homedir flag 166 | set dist=%~n0 167 | 168 | rem start in current directory 169 | set cdir= 170 | rem if script name ends with ~, extract WSL distribution and param -~ 171 | if "%dist:~-1%" == "~" set cdir=-~ && set dist=%dist:~0,-1% 172 | rem map WSL default distribution 173 | if "%dist%" == "WSL" set dist= 174 | 175 | rem check if we have an explicit -d DIST parameter 176 | if "%1" == "-d" set dist=%2 && shift && shift 177 | 178 | chcp 65001 > nul: 179 | 180 | if "%1" == "" goto login 181 | 182 | :cmd 183 | "%LOCALAPPDATA%/wsltty/bin/mintty.exe" -i "%LOCALAPPDATA%/wsltty/wsl.ico" --WSL="%dist%" --configdir="%APPDATA%/wsltty" %cdir% %* 184 | goto end 185 | 186 | :login 187 | "%LOCALAPPDATA%/wsltty/bin/mintty.exe" -i "%LOCALAPPDATA%/wsltty/wsl.ico" --WSL="%dist%" --configdir="%APPDATA%/wsltty" %cdir% - 188 | 189 | :end 190 | /EOB 191 | } 192 | 193 | if $custominst && $config && ! $remove 194 | then 195 | #mkshortcut.exe -n "add to context menu" -a "$installdir/config-distros.sh -contextmenu" "$installdir/bin/dash.exe" -i '%SystemRoot%\System32\filemgmt.dll' -s min -d "" -w "$installdir" 196 | #mkshortcut.exe -n "add default to context menu" -a "$installdir/config-distros.sh -contextmenu-default" "$installdir/bin/dash.exe" -i '%SystemRoot%\System32\filemgmt.dll' -s min -d "" -w "$installdir" 197 | #mkshortcut.exe -n "remove from context menu" -a "$installdir/config-distros.sh -contextmenu-remove" "$installdir/bin/dash.exe" -i '%SystemRoot%\System32\filemgmt.dll' -s min -d "" -w "$installdir" 198 | #mkshortcut.exe -n "configure WSL shortcuts" -a "$installdir/config-distros.sh" "$installdir/bin/dash.exe" -i '%SystemRoot%\System32\filemgmt.dll' -s min -d "" -w "$installdir" 199 | 200 | icon='%SystemRoot%\System32\filemgmt.dll' 201 | wdir="$installdir" 202 | target="$installdir/bin/dash.exe" 203 | minttyargs="/config-distros.sh" 204 | bridgeargs= 205 | export icon wdir target minttyargs bridgeargs 206 | cscript /nologo mkshortcut.vbs "/name:configure WSL shortcuts" "/min:true" 207 | bridgeargs=-contextmenu 208 | cscript /nologo mkshortcut.vbs "/name:add to context menu" "/min:true" 209 | bridgeargs=-contextmenu-default 210 | cscript /nologo mkshortcut.vbs "/name:add default to context menu" "/min:true" 211 | bridgeargs=-contextmenu-remove 212 | cscript /nologo mkshortcut.vbs "/name:remove from context menu" "/min:true" 213 | 214 | copy "add to context menu.lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty" 215 | copy "add default to context menu.lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty" 216 | copy "remove from context menu.lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty" 217 | copy "configure WSL shortcuts.lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty" 218 | 219 | # restore target 220 | target="$installdir"'\bin\mintty.exe' 221 | fi 222 | 223 | lxss="/HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Lxss" 224 | schema="/HKEY_CURRENT_USER/Software/Classes/Local Settings/Software/Microsoft/Windows/CurrentVersion/AppModel/SystemAppData" 225 | 226 | appex () { 227 | while read line 228 | do 229 | case "$line" in 230 | *Application*Executable*) 231 | for item in $line 232 | do case "$item" in 233 | Executable=*) 234 | eval $item 235 | echo "$Executable" 236 | break;; 237 | esac 238 | done 239 | break;; 240 | esac 241 | done < $* 242 | } 243 | 244 | config () { 245 | guid="$1" 246 | ok=false 247 | case $guid in 248 | {*) 249 | distro=`regtool get "$lxss/$guid/DistributionName"` 250 | case "$distro" in 251 | Legacy) 252 | name="Bash on Windows" 253 | launcher="$SYSTEMROOT/System32/bash.exe" 254 | ;; 255 | *) name="$distro" 256 | launcher="$LOCALAPPDATA/Microsoft/WindowsApps/$distro.exe" 257 | ;; 258 | esac 259 | basepath=`regtool get "$lxss/$guid/BasePath"` 260 | if package=`regtool -q get "$lxss/$guid/PackageFamilyName"` 261 | then 262 | distrinst=`regtool get "$schema/$package/Schemas/PackageFullName"` 263 | # get actual executable path (may not match $distro) from app manifest 264 | manifest="$ProgramW6432/WindowsApps/$distrinst/AppxManifest.xml" 265 | psh_cmd='([xml]$(Get-Content '"\"$manifest\""')).Package.Applications.Application.Executable' 266 | executable=`appex "$manifest"` 267 | if [ -r "$ProgramW6432/WindowsApps/$distrinst/$executable" ] 268 | then icon="$ProgramW6432/WindowsApps/$distrinst/$executable" 269 | elif [ -r "$ProgramW6432/WindowsApps/$distrinst/images/icon.ico" ] 270 | then icon="$ProgramW6432/WindowsApps/$distrinst/images/icon.ico" 271 | else icon="$installcop"'\wsl.ico' 272 | fi 273 | root="$basepath/rootfs" 274 | elif [ -f "$basepath/$distro.exe" ] 275 | then 276 | icon="$basepath/$distro.exe" 277 | root="$basepath/rootfs" 278 | elif [ -d "$LOCALAPPDATA/lxss" ] 279 | then 280 | # legacy "Bash on Windows" 281 | icon="$LOCALAPPDATA/lxss/bash.ico" 282 | root="$basepath" 283 | else 284 | # imported distro? (#226, #236) 285 | icon="$installcop"'\wsl.ico' 286 | root="$basepath/rootfs" 287 | fi 288 | 289 | # invocation parameters for mintty 290 | minttyargs='--WSL="'"$distro"'" --configdir="'"$configdir"'"' 291 | # MINTARGS deprecated; used for mkshortcut.exe rather than mkshortcut.vbs 292 | MINTARGS='--WSL="'"$distro"'" --configdir="'"$CONFDIR"'"' 293 | # invocation commands (deprecated for mintty, used for start menu scripts) 294 | #bridgeargs='--distro-guid "'"$guid"'" -t' 295 | 296 | ok=true;; 297 | DefaultDistribution|"") # WSL default installation 298 | distro= 299 | name=WSL 300 | icon="$installcop"'\wsl.ico' 301 | minttyargs='--WSL= --configdir="'"$configdir"'"' 302 | MINTARGS='--WSL= --configdir="'"$CONFDIR"'"' 303 | #bridgeargs='-t' 304 | 305 | ok=true;; 306 | esac 307 | bridgeargs=" -" # now used to request login mode 308 | 309 | echoc "distro '$distro'" 310 | echoc "- name '$name'" 311 | echoc "- guid $guid" 312 | echoc "- (launcher $launcher)" 313 | echoc "- icon $icon" 314 | echoc "- root $root" 315 | wdir=%USERPROFILE% 316 | 317 | case "$name" in 318 | docker*) echo skipping docker system 319 | return;; 320 | esac 321 | case "$root" in 322 | *\\Docker*) echo skipping docker system 323 | return;; 324 | esac 325 | 326 | if $ok && ! $remove && [ -n "$distro" ] 327 | then # fix #163: backend missing +x with certain mount options 328 | echo Setting +x wslbridge2 backends for distro "'$distro'" 329 | (cd "$INSTDIR"; cd bin; PATH="${WINDIR}/Sysnative:${PATH}" wsl.exe -d "$distro" chmod +x wslbridge2-backend) 330 | # (cd "$LOCALAPPDATA/wsltty/bin"; wsl.exe -d "$distro" chmod +x wslbridge2-backend) 331 | # (cd ... ; "$SYSTEMROOT/System32/bash.exe" "$guid" -c chmod +x wslbridge2-backend) 332 | fi 333 | 334 | if $ok && $config 335 | then 336 | export wdir name target minttyargs bridgeargs icon 337 | 338 | if $contextmenu 339 | then 340 | # context menu entries 341 | direckey='HKEY_CURRENT_USER\Software\Classes\Directory' 342 | keyname="${name}_Terminal" 343 | if $remove 344 | then 345 | # obsolete; handled above 346 | reg delete "$direckey\\shell\\$keyname" /f 347 | reg delete "$direckey\\Background\\shell\\$keyname" /f 348 | else 349 | direckey='/HKEY_CURRENT_USER/Software/Classes/Directory' 350 | echoc Registry setting "$direckey/[Background/]shell/$keyname" 351 | target="$installcop"'\bin\mintty.exe' 352 | 353 | regtool add "$direckey/shell" 354 | regtool add "$direckey/shell/$keyname" 355 | regtool set "$direckey/shell/$keyname/" -s "$name Terminal" 356 | regtool set "$direckey/shell/$keyname/Icon" -s "$icon" 357 | regtool add "$direckey/shell/$keyname/command" 358 | regtool set "$direckey/shell/$keyname/command/" -s "\"$target\" -i \"$icon\" --dir \"%1\" $MINTARGS $bridgeargs" 359 | 360 | regtool add "$direckey/Background/shell" 361 | regtool add "$direckey/Background/shell/$keyname" 362 | regtool set "$direckey/Background/shell/$keyname/" -s "$name Terminal" 363 | regtool set "$direckey/Background/shell/$keyname/Icon" -s "$icon" 364 | regtool add "$direckey/Background/shell/$keyname/command" 365 | regtool set "$direckey/Background/shell/$keyname/command/" -s "\"$target\" -i \"$icon\" $MINTARGS $bridgeargs" 366 | fi 367 | else 368 | # invocation shortcuts and scripts 369 | if $remove 370 | then 371 | delete "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\$name Terminal.lnk" 372 | delete "$LOCALAPPDATA\\Microsoft\\WindowsApps\\$name.bat" 373 | delete "$LOCALAPPDATA\\Microsoft\\WindowsApps\\$name~.bat" 374 | 375 | if [ "$name" = "WSL" ] 376 | then 377 | # determine actual Desktop folder 378 | desktopkey='\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop' 379 | desktop=`regtool get "$desktopkey"` 380 | case "$desktop" in 381 | %USERPROFILE%*) desktop="$USERPROFILE${desktop#%USERPROFILE%}";; 382 | esac 383 | delete "$desktop\\$name Terminal.lnk" 384 | fi 385 | else 386 | # desktop shortcut in %USERPROFILE% -> Start Menu - WSLtty 387 | cscript /nologo mkshortcut.vbs "/name:$name Terminal %" 388 | #mkshortcut.exe -n "$name Terminal %" -i "$icon" "$TARGETPATH" -a "$MINTARGS" -d "" -w %USERPROFILE% 389 | copy "$name Terminal %.lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs\\WSLtty" 390 | 391 | # launch script in . -> WSLtty home, WindowsApps launch folder 392 | #cmd /C mkbat.bat "$name" 393 | mkbat "$name" 394 | copy "$name.bat" "$LOCALAPPDATA\\Microsoft\\WindowsApps" 395 | 396 | # store backup copies in installation dir 397 | if [ "$PWD" != "$INSTDIR" ] 398 | then 399 | copy "$name Terminal %.lnk" "$installcop" 400 | copy "$name.bat" "$installcop" 401 | fi 402 | 403 | # prepare versions to target WSL home directory 404 | #bridgeargs="-C~ $bridgeargs" 405 | minttyargs="$minttyargs -~" 406 | MINTARGS="$MINTARGS -~" 407 | 408 | # desktop shortcut in ~ -> Start Menu 409 | cscript /nologo mkshortcut.vbs "/name:$name Terminal" 410 | #mkshortcut.exe -n "$name Terminal" -i "$icon" "$TARGETPATH" -a "$MINTARGS" -d "" -w %USERPROFILE% 411 | copy "$name Terminal.lnk" "$APPDATA\\Microsoft\\Windows\\Start Menu\\Programs" 412 | 413 | # default desktop shortcut in ~ -> Desktop 414 | if [ "$name" = "WSL" ] 415 | then 416 | #copy "$name Terminal.lnk" "$USERPROFILE\\Desktop" 417 | #copy "$name Terminal.lnk" "$APPDATA\\..\\Desktop\\" 418 | # the above does not work reliably (see #166) 419 | # determine actual Desktop folder 420 | desktopkey='\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop' 421 | desktop=`regtool get "$desktopkey"` 422 | case "$desktop" in 423 | %USERPROFILE%*) desktop="$USERPROFILE${desktop#%USERPROFILE%}";; 424 | esac 425 | copy "$name Terminal.lnk" "$desktop\\" 426 | fi 427 | 428 | # launch script in ~ -> WSLtty home, WindowsApps launch folder 429 | #cmd /C mkbat.bat "$name~" 430 | mkbat "$name~" 431 | copy "$name~.bat" "$LOCALAPPDATA\\Microsoft\\WindowsApps" 432 | 433 | # store backup copies in installation dir 434 | if [ "$PWD" != "$INSTDIR" ] 435 | then 436 | copy "$name Terminal.lnk" "$installcop" 437 | copy "$name~.bat" "$installcop" 438 | fi 439 | fi 440 | 441 | fi 442 | fi 443 | } 444 | 445 | # ensure proper parameter passing to cmd /C 446 | chcp.com 65001 # just in case; seems to work without as well 447 | 448 | # configure for all distros, plus default distro 449 | for guid in ` 450 | if $alldistros 451 | then regtool list "$lxss" 2>/dev/null 452 | else echo DefaultDistribution 453 | fi || echo "No WSL packages registered" >&2 454 | ` 455 | do config $guid 456 | done 457 | 458 | -------------------------------------------------------------------------------- /configure WSL shortcuts.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/configure WSL shortcuts.lnk -------------------------------------------------------------------------------- /dequote.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem https://ss64.com/nt/syntax-dequote.html 3 | for /f "delims=" %%A in ('echo %%%1%%') do set %1=%%~A 4 | -------------------------------------------------------------------------------- /install-portable.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | chcp 65001 > nul 4 | 5 | if not exist "WSL Terminal Portable.lnk" goto install 6 | echo Rebuilding WSL Terminal Portable shortcut 7 | set instdir=%~dp0 8 | goto shortcut 9 | 10 | :install 11 | 12 | echo Installing WSL Terminal Portable 13 | echo Select target folder in popup dialog ... 14 | 15 | set sel="Select folder to place installation of portable wsltty" 16 | 17 | for /f "usebackq delims=" %%f in (`powershell "(new-object -COM Shell.Application).BrowseForFolder(0, '%sel%', 0, 0).self.path"`) do set f=%%f 18 | set instdir=%f%\wsltty 19 | if exist %f%\LICENSE.mintty set instdir=%f% 20 | 21 | if "%f%"=="" ( 22 | echo No installation selected 23 | pause 24 | exit 25 | ) else if not exist "%f%" ( 26 | echo Invalid installation folder %instdir% 27 | pause 28 | exit 29 | ) 30 | 31 | rem call main installation 32 | call install "%instdir%" "%instdir%" /P 33 | rem this already changes into "%instdir%" 34 | 35 | rem copy additional portable installation files 36 | rem do this after call install as that deletes previous .bat files 37 | copy "%~dp0\install-portable.bat" . 38 | dir "%instdir%"\install-portable.bat 39 | 40 | :shortcut 41 | 42 | rem create shortcut 43 | cd /D "%instdir%" 44 | rem set drive-relative path for shortcut working directory and icon 45 | set instpath=%instdir:~2% 46 | set target=%%COMSPEC%% 47 | set minttyargs=/C bin\mintty.exe --WSL= --icon=/wsl.ico --configdir=. -~ 48 | set bridgeargs= - 49 | rem set wdir=%instpath% 50 | rem let mkshortcut set working directory to empty: 51 | set wdir=. 52 | set icon=%instpath%\wsl.ico 53 | cscript /nologo mkshortcut.vbs "/name:WSL Terminal Portable" 54 | 55 | -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set refinstalldir=%%LOCALAPPDATA%%\wsltty 4 | set refconfigdir=%%APPDATA%%\wsltty 5 | if "%installdir%" == "" set installdir="%LOCALAPPDATA%\wsltty" 6 | if "%configdir%" == "" set configdir="%APPDATA%\wsltty" 7 | call dequote installdir 8 | call dequote configdir 9 | set oldroot="%installdir%" 10 | set oldhomedir="%installdir%\home\%USERNAME%" 11 | call dequote oldroot 12 | call dequote oldhomedir 13 | set oldconfigdir="%oldhomedir%\.config\mintty" 14 | call dequote oldconfigdir 15 | 16 | rem override installdir, configdir if parameters given 17 | set arg1=%1 18 | call dequote arg1 19 | if "%arg1%" == "%%arg1%%" goto deploy 20 | set refinstalldir=%arg1% 21 | set installdir=%arg1% 22 | set arg2=%2 23 | call dequote arg2 24 | if "%arg2%" == "%%arg2%%" goto deploy 25 | set refconfigdir=%arg2% 26 | set configdir=%arg2% 27 | 28 | :deploy 29 | 30 | mkdir "%installdir%" 2> nul: 31 | 32 | rem clean up previous installation artefacts 33 | del /Q "%installdir%\*.bat" 34 | del /Q "%installdir%\*.lnk" 35 | 36 | copy LICENSE.mintty "%installdir%" 37 | copy LICENSE.wslbridge2 "%installdir%" 38 | 39 | copy "add to context menu.lnk" "%installdir%" 40 | copy "add default to context menu.lnk" "%installdir%" 41 | copy "remove from context menu.lnk" "%installdir%" 42 | copy "configure WSL shortcuts.lnk" "%installdir%" 43 | rem copy "WSL Terminal.lnk" "%installdir%" 44 | rem copy "WSL Terminal %%.lnk" "%installdir%" 45 | copy config-distros.sh "%installdir%" 46 | 47 | copy mkshortcut.vbs "%installdir%" 48 | copy cmd2.bat "%installdir%" 49 | copy dequote.bat "%installdir%" 50 | 51 | rem allow persistent customization of default icon: 52 | if not exist "%installdir%\wsl.ico" copy tux.ico "%installdir%\wsl.ico" 53 | 54 | copy uninstall.bat "%installdir%" 55 | 56 | if not exist "%installdir%\bin" goto instbin 57 | rem move previous programs possibly in use out of the way 58 | del /Q "%installdir%\bin\*.old" 2> nul: 59 | ren "%installdir%\bin\cygwin1.dll" cygwin1.dll.old 60 | ren "%installdir%\bin\cygwin-console-helper.exe" cygwin-console-helper.exe.old 61 | ren "%installdir%\bin\mintty.exe" mintty.exe.old 62 | ren "%installdir%\bin\wslbridge2.exe" wslbridge2.exe.old 63 | ren "%installdir%\bin\wslbridge2-backend" wslbridge2-backend.old 64 | del /Q "%installdir%\bin\*.old" 2> nul: 65 | 66 | :instbin 67 | mkdir "%installdir%\bin" 2> nul: 68 | copy cygwin1.dll "%installdir%\bin" 69 | copy cygwin-console-helper.exe "%installdir%\bin" 70 | copy mintty.exe "%installdir%\bin" 71 | copy wslbridge2.exe "%installdir%\bin" 72 | copy wslbridge2-backend "%installdir%\bin" 73 | 74 | copy dash.exe "%installdir%\bin" 75 | copy regtool.exe "%installdir%\bin" 76 | copy zoo.exe "%installdir%\bin" 77 | 78 | rem copy mkshortcut.exe "%installdir%"\bin 79 | rem copy cygpopt-0.dll "%installdir%"\bin 80 | rem copy cygiconv-2.dll "%installdir%"\bin 81 | rem copy cygintl-8.dll "%installdir%"\bin 82 | 83 | rem create system config directory and copy config archive and scripts 84 | mkdir "%installdir%\usr\share\mintty\lang" 2> nul: 85 | copy lang.zoo "%installdir%\usr\share\mintty\lang" 86 | mkdir "%installdir%\usr\share\mintty\themes" 2> nul: 87 | copy themes.zoo "%installdir%\usr\share\mintty\themes" 88 | mkdir "%installdir%\usr\share\mintty\sounds" 2> nul: 89 | copy sounds.zoo "%installdir%\usr\share\mintty\sounds" 90 | mkdir "%installdir%\usr\share\mintty\info" 2> nul: 91 | copy charnames.txt "%installdir%\usr\share\mintty\info" 92 | mkdir "%installdir%\usr\share\mintty\icon" 2> nul: 93 | copy tux.ico "%installdir%\usr\share\mintty\icon" 94 | copy mintty.ico "%installdir%\usr\share\mintty\icon" 95 | mkdir "%installdir%\usr\share\mintty\emojis" 2> nul: 96 | copy getemojis "%installdir%\usr\share\mintty\emojis" 2> nul: 97 | copy getflags "%installdir%\usr\share\mintty\emojis" 2> nul: 98 | 99 | 100 | rem create Start Menu Folder 101 | set smf="%APPDATA%\Microsoft\Windows\Start Menu\Programs\WSLtty" 102 | call dequote smf 103 | mkdir "%smf%" 2> nul: 104 | 105 | rem clean up previous installation 106 | del /Q "%smf%\*.lnk" 107 | 108 | copy "wsltty home & help.url" "%smf%" 109 | copy "add to context menu.lnk" "%smf%" 110 | copy "add default to context menu.lnk" "%smf%" 111 | copy "remove from context menu.lnk" "%smf%" 112 | copy "configure WSL shortcuts.lnk" "%smf%" 113 | rem copy "WSL Terminal.lnk" "%smf%" 114 | rem copy "WSL Terminal %%.lnk" "%smf%" 115 | rem clean up previous installation 116 | rmdir /S /Q "%smf%\context menu shortcuts" 2> nul: 117 | 118 | rem unpack config files in system config directory 119 | cd /D "%installdir%\usr\share\mintty\lang" 120 | "%installdir%\bin\zoo" xO lang 121 | cd /D "%installdir%\usr\share\mintty\themes" 122 | "%installdir%\bin\zoo" xO themes 123 | cd /D "%installdir%\usr\share\mintty\sounds" 124 | "%installdir%\bin\zoo" xO sounds 125 | cd /D "%installdir%" 126 | 127 | 128 | :migrate configuration 129 | 130 | rem migrate old config resource files to new config dir 131 | if exist "%configdir%" goto configfile 132 | if not exist "%oldconfigdir%" goto configfile 133 | if exist "%oldhomedir%\.minttyrc" copy "%oldhomedir%\.minttyrc" "%oldconfigdir%\config" && del "%oldhomedir%\.minttyrc" 134 | xcopy /E /I /Y "%oldconfigdir%" "%configdir%" && rmdir /S /Q "%oldconfigdir%" 135 | rmdir "%oldhomedir%\.config" 136 | :configfile 137 | if exist "%configdir%\config" goto deloldhome 138 | if exist "%oldhomedir%\.minttyrc" copy "%oldhomedir%\.minttyrc" "%configdir%\config" && del "%oldhomedir%\.minttyrc" 139 | :deloldhome 140 | rmdir "%oldhomedir%" 2> nul: 141 | rmdir "%oldroot%\home" 2> nul: 142 | 143 | 144 | :userconfig 145 | 146 | rem create user config directory and subfolders, copy scripts 147 | mkdir "%configdir%\lang" 2> nul: 148 | mkdir "%configdir%\themes" 2> nul: 149 | mkdir "%configdir%\sounds" 2> nul: 150 | mkdir "%configdir%\emojis" 2> nul: 151 | copy "%installdir%\usr\share\mintty\emojis\getemojis" "%configdir%\emojis" 2> nul: 152 | copy "%installdir%\usr\share\mintty\emojis\getflags" "%configdir%\emojis" 2> nul: 153 | 154 | rem create config file if it does not yet exist 155 | if exist "%configdir%\config" goto appconfig 156 | echo # To use common configuration in %%APPDATA%%\mintty, simply remove this file>"%configdir%\config" 157 | if "%3" == "/P" echo # Do not remove this file for WSLtty Portable>>"%configdir%\config" 158 | 159 | 160 | :appconfig 161 | 162 | rem skip configuration for WSLtty Portable 163 | if "%3" == "/P" goto end 164 | 165 | rem distro-specific stuff: shortcuts and launch scripts 166 | cd /D "%installdir%" 167 | echo Configuring for WSL distributions 168 | bin\dash.exe "config-distros.sh" 169 | rem rem bin\dash.exe "config-distros.sh" -contextmenu 170 | 171 | 172 | :end 173 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # build a wsltty installer package: 3 | # configure ver=... and minttyver= in this makefile 4 | # make targets: 5 | # make [all] build a distributable installer (default) 6 | # make pkg build an installer, bypassing the system checks 7 | # make build build the software (no installer) 8 | # make install install wsltty locally from build (no installer needed) 9 | # make wsltty build the software, using the local copy of mintty 10 | 11 | 12 | # wsltty release 13 | ver=3.7.8 14 | 15 | # wsltty appx release - must have 4 parts! 16 | verx=3.7.8.1 17 | 18 | 19 | ############################## 20 | # mintty release version 21 | 22 | minttyver=3.7.8 23 | 24 | minrepo=git@github.com:mintty/mintty.git 25 | 26 | ############################## 27 | 28 | # wslbridge2 repository and release version 29 | repo=Biswa96/wslbridge2 30 | wslbridgever=0.13 31 | 32 | # wslbridge2 fork repository and version 33 | #repo=mintty/wslbridge2 34 | #wslbridgever=0.5.1 35 | 36 | 37 | # wslbridge2 release or fork archive and dir 38 | archive=v$(wslbridgever) 39 | wslbridgedir=wslbridge2-$(wslbridgever) 40 | 41 | 42 | # wslbridge2 latest version 43 | #archive=master 44 | #wslbridgedir=wslbridge2-$(archive) 45 | 46 | 47 | # wslbridge2 branch or commit version (from fix-window-resize branch) and dir 48 | #commit=70e0dcea1db122d076ce1578f2a45280cc92d09f 49 | #commit=8b6dd7ee2b3102d72248990c21764c5cf86c6612 50 | # trying post-0.12 WSL V2 patches: 51 | #commit=5b2b652d1a7355b004e7860b4370a585737e5ac9 52 | #commit=274530b35a05df203d3a69f0e28d5015844f39bd 53 | # pixel size patch + fix (retagged as 0.13): 54 | #commit=a7162d852ff438d2d5a8dd8dae61795addb3d980 55 | #archive=$(commit) 56 | #wslbridgedir=wslbridge2-$(archive) 57 | 58 | 59 | ############################## 60 | 61 | # mintty branch or commit version 62 | #minttyver=master 63 | 64 | # wslbridge branch or commit to build from source; 65 | wslbridge=wslbridge-source wslbridge-frontend wslbridge-backend 66 | 67 | ############################## 68 | # build backend on a musl-libc-based distribution 69 | # (reportedly not needed anymore but untested) 70 | BuildDistr=-d Alpine 71 | 72 | ############################## 73 | # Windows SDK version for appx 74 | WINSDKKEY=/HKEY_LOCAL_MACHINE/SOFTWARE/WOW6432Node/Microsoft/.NET Framework Platform/Setup/Multi-Targeting Pack 75 | WINSDKVER=`regtool list '$(WINSDKKEY)' | sed -e '$$ q' -e d` 76 | 77 | ############################################################################# 78 | # default target 79 | 80 | all: all-$(notdir $(CURDIR)) 81 | 82 | # targets and version checking 83 | 84 | all-wsltty: check committed pkg 85 | 86 | all-wsltty.appx: appx 87 | 88 | committed: 89 | if git status -suno | sed -e "s,^..,," | grep .; then false; fi 90 | 91 | ############################################################################# 92 | # target checking and some defs 93 | 94 | TARGET := $(shell $(CC) -dumpmachine) 95 | 96 | ifeq ($(TARGET), i686-pc-cygwin) 97 | sys := cygwin32 98 | else ifeq ($(TARGET), x86_64-pc-cygwin) 99 | sys := cygwin64 100 | else ifeq ($(TARGET), i686-pc-msys) 101 | sys := msys32 102 | else ifeq ($(TARGET), x86_64-pc-msys) 103 | sys := msys64 104 | else 105 | $(error Target '$(TARGET)' not supported) 106 | endif 107 | 108 | wget=curl -R -L --connect-timeout 55 -O 109 | wgeto=curl -R -L --connect-timeout 55 110 | 111 | ############################################################################# 112 | # system check: 113 | # - ensure the path name drag-and-drop adaptation works (-> Cygwin, not MSYS) 114 | # - 64 Bit (x86_64) for more stable invocation (avoid fork issues) 115 | 116 | arch:=$(shell uname -m) 117 | 118 | check: # checkarch 119 | echo Building for: 120 | echo $(arch) | grep . 121 | # checking suitable host environment; run `make pkg` to bypass 122 | # check cygwin (vs msys) for proper drag-and-drop paths: 123 | uname | grep CYGWIN 124 | 125 | checkarch: 126 | # check 32 bit to ensure 32-Bit Windows support, just in case: 127 | #uname -m | grep i686 128 | # check 64 bit to provide 64-Bit stability support: 129 | #uname -m | grep x86_64 130 | 131 | ############################################################################# 132 | # patch version information for appx package configuration 133 | 134 | fix-verx: 135 | echo patching $(WINSDKVER) into Launcher config 136 | cd Launcher; sed -i~ -e "// s,v[.0-9]*,$(WINSDKVER)," Launcher.csproj 139 | echo patched Launcher.csproj 140 | echo patching $(verx) into app config 141 | sed -i~ -e '/ rel/wsltty.SED 320 | # build installer 321 | cd rel; iexpress /n wsltty.SED 322 | 323 | silent-installer: 324 | # prepare build of installer 325 | rm -f rel/$(CAB)-install-quiet.exe 326 | cd rel; sed -e "/ShowInstallProgramWindow/ s/0/1/" -e "/HideExtractAnimation/ s/0/1/" -e "/InstallPrompt/ s/=.*/=/" -e "/FinishMessage/ s/=.*/=/" -e "/TargetName/ s/install.exe/install-quiet.exe/" wsltty.SED > wsltty-quiet.SED 327 | # build installer 328 | cd rel; iexpress /n wsltty-quiet.SED 329 | 330 | InstallPrompt=Install Mintty terminal for WSL Portable? 331 | FinishMessage=Mintty for WSL Portable installation finished 332 | 333 | portable-installer: 334 | # prepare build of installer 335 | rm -f rel/$(CAB)-install-portable.exe 336 | cd rel; sed -e "/InstallPrompt/ s/=.*/=$(InstallPrompt)/" -e "/FinishMessage/ s/=.*/=$(FinishMessage)/" -e "/AppLaunched/ s/install/install-portable/" -e "/TargetName/ s/install.exe/install-portable.exe/" wsltty.SED > wsltty-portable.SED 337 | # build installer 338 | cd rel; iexpress /n wsltty-portable.SED 339 | 340 | install: cop installbat 341 | 342 | installbat: 343 | cd rel; cmd /C install 344 | 345 | ver: 346 | echo $(ver) > VERSION 347 | 348 | mintty: mintty-get mintty-build 349 | 350 | mintty-usr: mintty-get mintty-appx 351 | 352 | # local wsltty build target: 353 | wsltty: wslbridge cygwin mintty-build mintty-pkg 354 | 355 | # build software without installer: 356 | build: wslbridge cygwin mintty-get mintty-build mintty-pkg 357 | 358 | # standalone wsltty package build target: 359 | pkg: wslbridge cygwin mintty-get mintty-build mintty-pkg installer 360 | 361 | # appx package contents target: 362 | wsltty-appx: wslbridge appx-bin mintty-get mintty-build-appx mintty-appx 363 | 364 | # appx package target: 365 | appx: wsltty-appx fix-verx 366 | sh ./build.sh 367 | 368 | ############################################################################# 369 | # end 370 | -------------------------------------------------------------------------------- /makewinx.cfg: -------------------------------------------------------------------------------- 1 | [Version] 2 | Class=IEXPRESS 3 | SEDVersion=3 4 | 5 | [Options] 6 | PackagePurpose=InstallApp 7 | ShowInstallProgramWindow=0 8 | HideExtractAnimation=0 9 | UseLongFileName=1 10 | InsideCompressed=0 11 | CAB_FixedSize=0 12 | CAB_ResvCodeSigning=0 13 | RebootMode=N 14 | InstallPrompt=%InstallPrompt% 15 | DisplayLicense=%DisplayLicense% 16 | FinishMessage=%FinishMessage% 17 | TargetName=%TargetName% 18 | FriendlyName=%FriendlyName% 19 | AppLaunched=%AppLaunched% 20 | PostInstallCmd=%PostInstallCmd% 21 | AdminQuietInstCmd=%AdminQuietInstCmd% 22 | UserQuietInstCmd=%UserQuietInstCmd% 23 | SourceFiles=SourceFiles 24 | 25 | [Strings] 26 | InstallPrompt=Install Mintty terminal for WSL? 27 | DisplayLicense= 28 | FinishMessage=Mintty for WSL installed - for documentation and configuration see https://github.com/mintty/wsltty 29 | TargetName=wsltty-%version%-%arch%-install.exe 30 | FriendlyName=wsltty 31 | AppLaunched=cmd.exe /c install.bat 32 | PostInstallCmd= 33 | AdminQuietInstCmd= 34 | UserQuietInstCmd= 35 | FILE0="cygwin1.dll" 36 | FILE1="cygwin-console-helper.exe" 37 | FILE2="mintty.exe" 38 | FILE3="wslbridge2.exe" 39 | FILE4="wslbridge2-backend" 40 | FILE5="LICENSE.mintty" 41 | FILE6="LICENSE.wslbridge2" 42 | FILE7="config-distros.sh" 43 | FILE8="configure WSL shortcuts.lnk" 44 | FILE9="charnames.txt" 45 | FILE10="VERSION" 46 | FILE11="dash.exe" 47 | FILE12="regtool.exe" 48 | FILE13="install.bat" 49 | FILE14="uninstall.bat" 50 | FILE15="tux.ico" 51 | FILE16="add to context menu.lnk" 52 | FILE17="add default to context menu.lnk" 53 | FILE18="remove from context menu.lnk" 54 | FILE19="wsltty home & help.url" 55 | FILE20="zoo.exe" 56 | FILE21="lang.zoo" 57 | FILE22="themes.zoo" 58 | FILE23="sounds.zoo" 59 | FILE24="mintty.ico" 60 | FILE25="mkshortcut.vbs" 61 | FILE26="dequote.bat" 62 | FILE27="cmd2.bat" 63 | FILE28="install-portable.bat" 64 | FILE29="getemojis" 65 | FILE30="getflags" 66 | 67 | [SourceFiles] 68 | SourceFiles0=. 69 | 70 | [SourceFiles0] 71 | %FILE0%= 72 | %FILE1%= 73 | %FILE2%= 74 | %FILE3%= 75 | %FILE4%= 76 | %FILE5%= 77 | %FILE6%= 78 | %FILE7%= 79 | %FILE8%= 80 | %FILE9%= 81 | %FILE10%= 82 | %FILE11%= 83 | %FILE12%= 84 | %FILE13%= 85 | %FILE14%= 86 | %FILE15%= 87 | %FILE16%= 88 | %FILE17%= 89 | %FILE18%= 90 | %FILE19%= 91 | %FILE20%= 92 | %FILE21%= 93 | %FILE22%= 94 | %FILE23%= 95 | %FILE24%= 96 | %FILE25%= 97 | %FILE26%= 98 | %FILE27%= 99 | %FILE28%= 100 | %FILE29%= 101 | %FILE30%= 102 | 103 | -------------------------------------------------------------------------------- /mkshortcut.c: -------------------------------------------------------------------------------- 1 | /* This is a tweaked version of mkshortcut.c -- create a Windows shortcut 2 | Changes: 3 | * Facilitate path entries starting with Windows environment variables. 4 | (works for working directory and icon location but not for target path) 5 | * Do not barf on Windows path syntax. 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define dont_debug_cygwin_create_path 13 | 14 | /* Preserve leading Windows environment variable for shortcut entries. 15 | So e.g. %USERPROFILE% is not pseudo-resolved to some subdirectory 16 | but can be used as working directory. 17 | NOTE: 18 | This works for working directory and icon location but not for the 19 | target path which is still polluted with a drive prefix by Windows. 20 | */ 21 | void * _cygwin_create_path (int line, cygwin_conv_path_t what, const void *from) 22 | { 23 | what &= CCP_CONVTYPE_MASK; 24 | void * to = cygwin_create_path(what, from); 25 | if (what == CCP_WIN_W_TO_POSIX ? *(wchar_t*)from == '%' : *(char*)from == '%') { 26 | if (what == CCP_POSIX_TO_WIN_W) { 27 | to = wcschr(to, '%') ?: to; 28 | } else { 29 | to = strchr(to, '%') ?: to; 30 | } 31 | } 32 | #ifdef debug_cygwin_create_path 33 | switch (what) { 34 | case CCP_POSIX_TO_WIN_A: 35 | printf("[%d] %s -> %s\n", line, from, to); 36 | break; 37 | case CCP_POSIX_TO_WIN_W: 38 | printf("[%d] %s -> %ls\n", line, from, to); 39 | break; 40 | case CCP_WIN_A_TO_POSIX: 41 | printf("[%d] %s -> %s\n", line, from, to); 42 | break; 43 | case CCP_WIN_W_TO_POSIX: 44 | printf("[%d] %ls -> %s\n", line, from, to); 45 | break; 46 | } 47 | #endif 48 | return to; 49 | } 50 | 51 | #define cygwin_create_path(what, from) _cygwin_create_path(__LINE__, what, from) 52 | 53 | 54 | /* mkshortcut.c -- create a Windows shortcut 55 | * 56 | * Copyright (c) 2002 Joshua Daniel Franklin 57 | * 58 | * Unicode-enabled by (C) 2015 Thomas Wolff 59 | * semantic changes: 60 | Allow dir to be empty (legal in shortcut) 61 | * 62 | * This program is free software: you can redistribute it and/or modify 63 | * it under the terms of the GNU General Public License as published by 64 | * the Free Software Foundation, either version 3 of the License, or 65 | * (at your option) any later version. 66 | * 67 | * This program is distributed in the hope that it will be useful, 68 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 69 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 70 | * GNU General Public License for more details. 71 | * 72 | * You should have received a copy of the GNU General Public License 73 | * along with this program. If not, see . 74 | * 75 | * See the COPYING file for full license information. 76 | * 77 | * Exit values 78 | * 1: user error (syntax error) 79 | * 2: system error (out of memory, etc.) 80 | * 3: windows error (interface failed) 81 | * 82 | * Compile with: gcc -o mkshortcut mkshortcut.c -lpopt -lole32 /usr/lib/w32api/libuuid.a 83 | * (You'd need to uncomment the moved to common.h lines.) 84 | * 85 | */ 86 | 87 | #if HAVE_CONFIG_H 88 | # include "config.h" 89 | #endif 90 | 91 | //#include "common.h" 92 | #include 93 | #include 94 | #include 95 | #include 96 | #define PACKAGE_VERSION "*" 97 | 98 | #include 99 | 100 | #include 101 | 102 | #define NOCOMATTRIBUTE 103 | 104 | #include 105 | #include 106 | /* moved to common.h */ 107 | /* 108 | #include 109 | #include 110 | */ 111 | #include 112 | #include // strlen 113 | 114 | 115 | static const char versionID[] = PACKAGE_VERSION; 116 | static const char revID[] = 117 | "$Id$"; 118 | static const char copyrightID[] = 119 | "Copyright (c) 2002\nJoshua Daniel Franklin. All rights reserved.\nLicensed under GPL v2.0\n"; 120 | 121 | typedef struct optvals_s 122 | { 123 | int icon_flag; 124 | int unix_flag; 125 | int windows_flag; 126 | int allusers_flag; 127 | int desktop_flag; 128 | int smprograms_flag; 129 | int show_flag; 130 | int offset; 131 | char *name_arg; 132 | char *desc_arg; 133 | char *dir_name_arg; 134 | char *argument_arg; 135 | char *target_arg; 136 | char *icon_name_arg; 137 | } optvals; 138 | 139 | static int mkshortcut (optvals opts); 140 | static void printTopDescription (FILE * f, char *name); 141 | static void printBottomDescription (FILE * f, char *name); 142 | static const char *getVersion (); 143 | static void usage (FILE * f, char *name); 144 | static void help (FILE * f, char *name); 145 | static void version (FILE * f, char *name); 146 | static void license (FILE * f, char *name); 147 | 148 | static char *program_name; 149 | static poptContext optCon; 150 | 151 | static WCHAR * 152 | towcs (const char * s) 153 | { 154 | int sizew = (strlen (s) * 2 + 1); // worst case: surrogates 155 | WCHAR * ws = malloc (sizew * sizeof (WCHAR)); 156 | mbstowcs (ws, s, sizew); 157 | return ws; 158 | } 159 | 160 | int 161 | main (int argc, const char **argv) 162 | { 163 | const char **rest; 164 | int rc; 165 | int ec = 0; 166 | optvals opts; 167 | 168 | const char *tmp_str; 169 | int icon_offset_flag; 170 | const char *arg; 171 | 172 | struct poptOption helpOptionsTable[] = { 173 | {"help", 'h', POPT_ARG_NONE, NULL, '?', 174 | "Show this help message", NULL}, 175 | {"usage", '\0', POPT_ARG_NONE, NULL, 'u', 176 | "Display brief usage message", NULL}, 177 | {"version", 'v', POPT_ARG_NONE, NULL, 'v', 178 | "Display version information", NULL}, 179 | {"license", '\0', POPT_ARG_NONE, NULL, 'l', 180 | "Display licensing information", NULL}, 181 | {NULL, '\0', 0, NULL, 0, NULL, NULL} 182 | }; 183 | 184 | struct poptOption generalOptionsTable[] = { 185 | {"arguments", 'a', POPT_ARG_STRING, NULL, 'a', 186 | "Use arguments ARGS", "ARGS"}, 187 | {"desc", 'd', POPT_ARG_STRING, NULL, 'd', 188 | "Text for description/tooltip (defaults to POSIX path of TARGET)", 189 | "DESC"}, 190 | {"icon", 'i', POPT_ARG_STRING, NULL, 'i', 191 | "Icon file for link to use", "ICONFILE"}, 192 | {"iconoffset", 'j', POPT_ARG_INT, &(opts.offset), 'j', 193 | "Offset of icon in icon file (default is 0)", NULL}, 194 | {"name", 'n', POPT_ARG_STRING, NULL, 'n', 195 | "Name for link (defaults to TARGET)", "NAME"}, 196 | {"show", 's', POPT_ARG_STRING, NULL, 's', 197 | "Window to show: normal, minimized, maximized", "norm|min|max"}, 198 | {"workingdir", 'w', POPT_ARG_STRING, NULL, 'w', 199 | "Set working directory (defaults to directory path of TARGET)", "PATH"}, 200 | {"allusers", 'A', POPT_ARG_VAL, &(opts.allusers_flag), 1, 201 | "Use 'All Users' instead of current user for -D,-P", NULL}, 202 | {"desktop", 'D', POPT_ARG_VAL, &(opts.desktop_flag), 1, 203 | "Create link relative to 'Desktop' directory", NULL}, 204 | {"smprograms", 'P', POPT_ARG_VAL, &(opts.smprograms_flag), 1, 205 | "Create link relative to Start Menu 'Programs' directory", NULL}, 206 | {NULL, '\0', 0, NULL, 0, NULL, NULL} 207 | }; 208 | 209 | struct poptOption opt[] = { 210 | {NULL, '\0', POPT_ARG_INCLUDE_TABLE, generalOptionsTable, 0, 211 | "General options", NULL}, 212 | {NULL, '\0', POPT_ARG_INCLUDE_TABLE, helpOptionsTable, 0, 213 | "Help options", NULL}, 214 | {NULL, '\0', 0, NULL, 0, NULL, NULL} 215 | }; 216 | 217 | setlocale (LC_CTYPE, ""); 218 | 219 | tmp_str = strrchr (argv[0], '/'); 220 | if (tmp_str == NULL) 221 | { 222 | tmp_str = strrchr (argv[0], '\\'); 223 | } 224 | if (tmp_str == NULL) 225 | { 226 | tmp_str = argv[0]; 227 | } 228 | else 229 | { 230 | tmp_str++; 231 | } 232 | if ((program_name = strdup (tmp_str)) == NULL) 233 | { 234 | fprintf (stderr, "%s: memory allocation error\n", argv[0]); 235 | exit (2); 236 | } 237 | 238 | icon_offset_flag = 0; 239 | 240 | opts.offset = 0; 241 | opts.icon_flag = 0; 242 | opts.unix_flag = 0; 243 | opts.windows_flag = 0; 244 | opts.allusers_flag = 0; 245 | opts.desktop_flag = 0; 246 | opts.smprograms_flag = 0; 247 | opts.show_flag = SW_SHOWNORMAL; 248 | opts.target_arg = NULL; 249 | opts.argument_arg = NULL; 250 | opts.name_arg = NULL; 251 | opts.desc_arg = NULL; 252 | opts.dir_name_arg = NULL; 253 | opts.icon_name_arg = NULL; 254 | 255 | /* Parse options */ 256 | optCon = poptGetContext (NULL, argc, argv, opt, 0); 257 | poptSetOtherOptionHelp (optCon, "[OPTION]* TARGET"); 258 | while ((rc = poptGetNextOpt (optCon)) > 0) 259 | { 260 | switch (rc) 261 | { 262 | case '?': 263 | help (stdout, program_name); 264 | goto exit; 265 | case 'u': 266 | usage (stdout, program_name); 267 | goto exit; 268 | case 'v': 269 | version (stdout, program_name); 270 | goto exit; 271 | case 'l': 272 | license (stdout, program_name); 273 | goto exit; 274 | case 'd': 275 | if (arg = poptGetOptArg (optCon)) 276 | { 277 | if ((opts.desc_arg = strdup (arg)) == NULL) 278 | { 279 | fprintf (stderr, "%s: memory allocation error\n", 280 | program_name); 281 | ec = 2; 282 | goto exit; 283 | } 284 | } 285 | break; 286 | case 'i': 287 | opts.icon_flag = 1; 288 | if (arg = poptGetOptArg (optCon)) 289 | { 290 | opts.icon_name_arg = (char *) cygwin_create_path ( 291 | CCP_POSIX_TO_WIN_A, arg); 292 | if (opts.icon_name_arg == NULL) 293 | { 294 | fprintf (stderr, "%s: error converting posix path to win32 (%s)\n", 295 | program_name, strerror (errno)); 296 | ec = 2; 297 | goto exit; 298 | } 299 | } 300 | break; 301 | case 'j': 302 | icon_offset_flag = 1; 303 | break; 304 | case 'n': 305 | if (arg = poptGetOptArg (optCon)) 306 | { 307 | if ((opts.name_arg = strdup (arg)) == NULL) 308 | { 309 | fprintf (stderr, "%s: memory allocation error\n", 310 | program_name); 311 | ec = 2; 312 | goto exit; 313 | } 314 | } 315 | break; 316 | case 's': 317 | if (arg = poptGetOptArg (optCon)) 318 | { 319 | if (strcmp (arg, "min") == 0) 320 | { 321 | opts.show_flag = SW_SHOWMINNOACTIVE; 322 | } 323 | else if (strcmp (arg, "max") == 0) 324 | { 325 | opts.show_flag = SW_SHOWMAXIMIZED; 326 | } 327 | else if (strcmp (arg, "norm") == 0) 328 | { 329 | opts.show_flag = SW_SHOWNORMAL; 330 | } 331 | else 332 | { 333 | fprintf (stderr, "%s: %s not valid for show window\n", 334 | program_name, arg); 335 | ec = 2; 336 | goto exit; 337 | } 338 | } 339 | break; 340 | case 'w': 341 | if (arg = poptGetOptArg (optCon)) 342 | { 343 | if ((opts.dir_name_arg = strdup (arg)) == NULL) 344 | { 345 | fprintf (stderr, "%s: memory allocation error\n", 346 | program_name); 347 | ec = 2; 348 | goto exit; 349 | } 350 | } 351 | break; 352 | case 'a': 353 | if (arg = poptGetOptArg (optCon)) 354 | { 355 | if ((opts.argument_arg = strdup (arg)) == NULL) 356 | { 357 | fprintf (stderr, "%s: memory allocation error\n", 358 | program_name); 359 | ec = 2; 360 | goto exit; 361 | } 362 | } 363 | break; 364 | // case 'A' 365 | // case 'D' 366 | // case 'P' all handled by popt itself 367 | } 368 | } 369 | 370 | if (icon_offset_flag & !opts.icon_flag) 371 | { 372 | fprintf (stderr, 373 | "%s: --iconoffset|-j only valid in conjuction with --icon|-i\n", 374 | program_name); 375 | usage (stderr, program_name); 376 | ec = 1; 377 | goto exit; 378 | } 379 | 380 | if (opts.smprograms_flag && opts.desktop_flag) 381 | { 382 | fprintf (stderr, 383 | "%s: --smprograms|-P not valid in conjuction with --desktop|-D\n", 384 | program_name); 385 | usage (stderr, program_name); 386 | ec = 1; 387 | goto exit; 388 | } 389 | 390 | if (rc < -1) 391 | { 392 | fprintf (stderr, "%s: bad argument %s: %s\n", 393 | program_name, poptBadOption (optCon, POPT_BADOPTION_NOALIAS), 394 | poptStrerror (rc)); 395 | ec = 1; 396 | goto exit; 397 | } 398 | 399 | rest = poptGetArgs (optCon); 400 | 401 | if (rest && *rest) 402 | { 403 | if ((opts.target_arg = strdup (*rest)) == NULL) 404 | { 405 | fprintf (stderr, "%s: memory allocation error\n", program_name); 406 | ec = 2; 407 | goto exit; 408 | } 409 | rest++; 410 | if (rest && *rest) 411 | { 412 | fprintf (stderr, "%s: Too many arguments: ", program_name); 413 | while (*rest) 414 | fprintf (stderr, "%s ", *rest++); 415 | fprintf (stderr, "\n"); 416 | usage (stderr, program_name); 417 | ec = 1; 418 | } 419 | else 420 | { 421 | // THE MEAT GOES HERE 422 | ec = mkshortcut (opts); 423 | } 424 | } 425 | else 426 | { 427 | fprintf (stderr, "%s: TARGET not specified\n", program_name); 428 | usage (stderr, program_name); 429 | ec = 1; 430 | } 431 | 432 | exit: 433 | return ec; 434 | } 435 | 436 | static char * 437 | xstrncat (char **dest, const char *add) 438 | { 439 | size_t n = strlen (add); 440 | size_t len = strlen (*dest) + n + 1; 441 | char *s = (char *) realloc (*dest, len * sizeof (char)); 442 | if (!s) 443 | { 444 | fprintf (stderr, "%s: out of memory\n", program_name); 445 | exit (2); 446 | } 447 | *dest = s; 448 | return strncat (*dest, add, n); 449 | } 450 | 451 | int 452 | mkshortcut (optvals opts) 453 | { 454 | char * link_name = NULL; 455 | WCHAR * exe_name = NULL; 456 | WCHAR * dir_name = NULL; 457 | WCHAR * desc = NULL; 458 | char * buf_str; 459 | char * tmp_str; 460 | char * base_str; 461 | int tmp; 462 | 463 | /* For OLE interface */ 464 | LPITEMIDLIST id; 465 | HRESULT hres; 466 | IShellLinkW * shell_link; 467 | IPersistFile * persist_file; 468 | 469 | exe_name = (WCHAR *) cygwin_create_path (CCP_POSIX_TO_WIN_W, opts.target_arg); 470 | if (!exe_name) 471 | { 472 | fprintf (stderr, "%s: error converting posix path to win32 (%s)\n", 473 | program_name, strerror (errno)); 474 | return 2; 475 | } 476 | 477 | #ifdef colon_stuff 478 | /* If there's a colon in the TARGET, it should be a URL */ 479 | if (strchr (opts.target_arg, ':') != NULL) 480 | { 481 | /* Nope, somebody's trying a W32 path */ 482 | if (opts.target_arg[1] == ':') 483 | { 484 | fprintf (stderr, "%s: all paths must be in POSIX format\n", 485 | program_name); 486 | usage (stderr, program_name); 487 | return 1; 488 | } 489 | dir_name = L""; 490 | } 491 | /* Convert TARGET to win32 path */ 492 | else 493 | #endif 494 | { 495 | buf_str = strdup (opts.target_arg); 496 | 497 | if (opts.dir_name_arg != NULL) 498 | /* Get a working dir from 'w' option */ 499 | { 500 | #ifdef colon_stuff 501 | if (strchr (opts.dir_name_arg, ':') != NULL) 502 | { 503 | fprintf (stderr, "%s: all paths must be in POSIX format\n", 504 | program_name); 505 | usage (stderr, program_name); 506 | return 1; 507 | } 508 | #endif 509 | dir_name = (WCHAR *) cygwin_create_path (CCP_POSIX_TO_WIN_W, 510 | opts.dir_name_arg); 511 | if (!dir_name) 512 | { 513 | fprintf (stderr, "%s: error converting posix path to win32 (%s)\n", 514 | program_name, strerror (errno)); 515 | return 2; 516 | } 517 | } 518 | else 519 | /* Allow dir to be empty (legal in shortcut) */ 520 | { 521 | dir_name = L""; 522 | } 523 | } 524 | 525 | /* Generate a name for the link if not given */ 526 | if (opts.name_arg == NULL) 527 | { 528 | /* Strip trailing /'s if any */ 529 | buf_str = strdup (opts.target_arg); 530 | base_str = buf_str; 531 | tmp_str = buf_str; 532 | tmp = strlen (buf_str) - 1; 533 | while (strrchr (buf_str, '/') == (buf_str + tmp)) 534 | { 535 | buf_str[tmp] = '\0'; 536 | tmp--; 537 | } 538 | /* Get basename */ 539 | while (*buf_str) 540 | { 541 | if (*buf_str == '/') 542 | tmp_str = buf_str + 1; 543 | buf_str++; 544 | } 545 | link_name = strdup (tmp_str); 546 | } 547 | /* User specified a name, so check it and convert */ 548 | else 549 | { 550 | if (opts.desktop_flag || opts.smprograms_flag) 551 | { 552 | /* Cannot have absolute path relative to Desktop/SM Programs */ 553 | if (opts.name_arg[0] == '/') 554 | { 555 | fprintf (stderr, 556 | "%s: absolute pathnames not allowed with -D/-P\n", 557 | program_name); 558 | usage (stderr, program_name); 559 | return 1; 560 | } 561 | } 562 | /* Sigh. Another W32 path */ 563 | #ifdef colon_stuff 564 | if (strchr (opts.name_arg, ':') != NULL) 565 | { 566 | fprintf (stderr, "%s: all paths must be in POSIX format\n", 567 | program_name); 568 | usage (stderr, program_name); 569 | return 1; 570 | } 571 | #endif 572 | link_name = (char *) cygwin_create_path ( 573 | CCP_POSIX_TO_WIN_A | CCP_RELATIVE, opts.name_arg); 574 | // passing multi-byte characters transparently per byte 575 | if (!link_name) 576 | { 577 | fprintf (stderr, "%s: error converting posix path to win32 (%s)\n", 578 | program_name, strerror (errno)); 579 | return 2; 580 | } 581 | } 582 | 583 | /* Add suffix to link name if necessary */ 584 | if (strlen (link_name) > 4) 585 | { 586 | tmp = strlen (link_name) - 4; 587 | if (strncmp (link_name + tmp, ".lnk", 4) != 0) 588 | xstrncat (&link_name, ".lnk"); 589 | } 590 | else 591 | xstrncat (&link_name, ".lnk"); 592 | 593 | /* Prepend relative path if necessary */ 594 | if (opts.desktop_flag) 595 | { 596 | char local_buf[MAX_PATH]; 597 | buf_str = strdup (link_name); 598 | 599 | if (!opts.allusers_flag) 600 | SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id); 601 | else 602 | SHGetSpecialFolderLocation (NULL, CSIDL_COMMON_DESKTOPDIRECTORY, &id); 603 | SHGetPathFromIDList (id, local_buf); 604 | /* Make sure Win95 without "All Users" has output */ 605 | if (strlen (local_buf) == 0) 606 | { 607 | SHGetSpecialFolderLocation (NULL, CSIDL_DESKTOPDIRECTORY, &id); 608 | SHGetPathFromIDList (id, local_buf); 609 | } 610 | link_name = strdup (local_buf); 611 | xstrncat (&link_name, "\\"); 612 | xstrncat (&link_name, buf_str); 613 | } 614 | 615 | if (opts.smprograms_flag) 616 | { 617 | char local_buf[MAX_PATH]; 618 | buf_str = strdup (link_name); 619 | 620 | if (!opts.allusers_flag) 621 | SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id); 622 | else 623 | SHGetSpecialFolderLocation (NULL, CSIDL_COMMON_PROGRAMS, &id); 624 | SHGetPathFromIDList (id, local_buf); 625 | /* Make sure Win95 without "All Users" has output */ 626 | if (strlen (local_buf) == 0) 627 | { 628 | SHGetSpecialFolderLocation (NULL, CSIDL_PROGRAMS, &id); 629 | SHGetPathFromIDList (id, local_buf); 630 | } 631 | link_name = strdup (local_buf); 632 | xstrncat (&link_name, "\\"); 633 | xstrncat (&link_name, buf_str); 634 | } 635 | 636 | /* Make link name Unicode-compliant */ 637 | WCHAR * widename = towcs (link_name); 638 | 639 | /* After Windows 7, saving link to relative path fails; work around that */ 640 | #ifdef corrupt_memory 641 | WCHAR widepath[MAX_PATH]; 642 | hres = GetFullPathNameW (widename, sizeof (widepath), widepath, NULL); 643 | if (hres == 0) 644 | { 645 | fprintf (stderr, "%s: Could not qualify link name\n", program_name); 646 | return 2; 647 | } 648 | #else 649 | WCHAR * widepath = (WCHAR *) cygwin_create_path (CCP_POSIX_TO_WIN_W, link_name); 650 | #endif 651 | link_name = (char *) cygwin_create_path (CCP_WIN_W_TO_POSIX, widepath); 652 | 653 | /* Setup description text */ 654 | if (opts.desc_arg != NULL) 655 | { 656 | desc = towcs (opts.desc_arg); 657 | } 658 | else 659 | { 660 | /* Put the POSIX path in the "Description", just to be nice */ 661 | desc = towcs (cygwin_create_path (CCP_WIN_A_TO_POSIX, exe_name)); 662 | if (!desc) 663 | { 664 | fprintf (stderr, "%s: error converting win32 path to posix (%s)\n", 665 | program_name, strerror (errno)); 666 | return 2; 667 | } 668 | } 669 | 670 | /* Beginning of Windows interface */ 671 | hres = OleInitialize (NULL); 672 | if (hres != S_FALSE && hres != S_OK) 673 | { 674 | fprintf (stderr, "%s: Could not initialize OLE interface\n", 675 | program_name); 676 | return 3; 677 | } 678 | 679 | hres = 680 | CoCreateInstance (&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, 681 | &IID_IShellLinkW, (void **) &shell_link); 682 | if (SUCCEEDED (hres)) 683 | { 684 | hres = 685 | shell_link->lpVtbl->QueryInterface (shell_link, &IID_IPersistFile, 686 | (void **) &persist_file); 687 | if (SUCCEEDED (hres)) 688 | { 689 | shell_link->lpVtbl->SetPath (shell_link, exe_name); 690 | shell_link->lpVtbl->SetDescription (shell_link, desc); 691 | shell_link->lpVtbl->SetWorkingDirectory (shell_link, dir_name); 692 | if (opts.argument_arg) 693 | shell_link->lpVtbl->SetArguments (shell_link, 694 | towcs (opts.argument_arg)); 695 | if (opts.icon_flag) 696 | shell_link->lpVtbl->SetIconLocation (shell_link, 697 | towcs (opts.icon_name_arg), 698 | opts.offset); 699 | if (opts.show_flag != SW_SHOWNORMAL) 700 | shell_link->lpVtbl->SetShowCmd (shell_link, opts.show_flag); 701 | 702 | hres = persist_file->lpVtbl->Save (persist_file, widepath, TRUE); 703 | if (!SUCCEEDED (hres)) 704 | { 705 | fprintf (stderr, 706 | "%s: Saving \"%s\" failed; does the target directory exist?\n", 707 | program_name, link_name); 708 | return 3; 709 | } 710 | persist_file->lpVtbl->Release (persist_file); 711 | shell_link->lpVtbl->Release (shell_link); 712 | 713 | /* If we are creating shortcut for all users, ensure it is readable by all users */ 714 | if (opts.allusers_flag) 715 | { 716 | char *posixpath = (char *) cygwin_create_path ( 717 | CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, widepath); 718 | if (posixpath && *posixpath) 719 | { 720 | struct stat statbuf; 721 | if (stat (posixpath, &statbuf)) 722 | { 723 | fprintf (stderr, 724 | "%s: stat \"%s\" failed\n", 725 | program_name, posixpath); 726 | } 727 | else if (chmod (posixpath, statbuf.st_mode|S_IRUSR|S_IRGRP|S_IROTH)) 728 | { 729 | fprintf (stderr, 730 | "%s: chmod \"%s\" failed\n", 731 | program_name, posixpath); 732 | } 733 | } 734 | } 735 | return 0; 736 | } 737 | else 738 | { 739 | fprintf (stderr, "%s: QueryInterface failed\n", program_name); 740 | return 3; 741 | } 742 | } 743 | else 744 | { 745 | fprintf (stderr, "%s: CoCreateInstance failed\n", program_name); 746 | return 3; 747 | } 748 | } 749 | 750 | static const char * 751 | getVersion () 752 | { 753 | return versionID; 754 | } 755 | 756 | static void 757 | printTopDescription (FILE * f, char *name) 758 | { 759 | char s[20]; 760 | fprintf (f, "%s is part of cygutils version %s\n", name, getVersion ()); 761 | fprintf (f, " create a Windows shortcut\n\n"); 762 | } 763 | 764 | static void 765 | printBottomDescription (FILE * f, char *name) 766 | { 767 | fprintf (f, 768 | "\nNOTE: All filename arguments must be in unix (POSIX) format\n"); 769 | } 770 | 771 | static void 772 | printLicense (FILE * f, char *name) 773 | { 774 | fprintf (f, 775 | "This program is free software: you can redistribute it and/or modify\n" 776 | "it under the terms of the GNU General Public License as published by\n" 777 | "the Free Software Foundation, either version 3 of the License, or\n" 778 | "(at your option) any later version.\n\n" 779 | "This program is distributed in the hope that it will be useful,\n" 780 | "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 781 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 782 | "GNU General Public License for more details.\n\n" 783 | "You should have received a copy of the GNU General Public License\n" 784 | "along with this program. If not, see .\n\n" 785 | "See the COPYING file for full license information.\n"); 786 | } 787 | 788 | static void 789 | usage (FILE * f, char *name) 790 | { 791 | poptPrintUsage (optCon, f, 0); 792 | } 793 | 794 | static void 795 | help (FILE * f, char *name) 796 | { 797 | printTopDescription (f, name); 798 | poptPrintHelp (optCon, f, 0); 799 | printBottomDescription (f, name); 800 | } 801 | 802 | static void 803 | version (FILE * f, char *name) 804 | { 805 | printTopDescription (f, name); 806 | fprintf (f, copyrightID); 807 | } 808 | 809 | static void 810 | license (FILE * f, char *name) 811 | { 812 | printTopDescription (f, name); 813 | printLicense (f, name); 814 | } 815 | -------------------------------------------------------------------------------- /mkshortcut.vbs: -------------------------------------------------------------------------------- 1 | rem cscript mkshortcut.vbs [/param:arg] /target:link 2 | 3 | rem /target:%LOCALAPPDATA%\wsltty\bin\mintty.exe 4 | rem /wdir:%USERPROFILE% 5 | rem /icon:%LOCALAPPDATA%\wsltty\wsl.ico 6 | rem deprecated: /icon:%LOCALAPPDATA%\lxss\bash.ico 7 | rem deprecated: % 8 | rem /arguments:--wsl -o Locale=C -o Charset=UTF-8 /bin/wslbridge -t /bin/bash 9 | rem deprecated: ~ 10 | rem /arguments:--wsl -o Locale=C -o Charset=UTF-8 /bin/wslbridge -C~ -t /bin/bash 11 | rem deprecated: -l 12 | rem /arguments:--wsl -o Locale=C -o Charset=UTF-8 /bin/wslbridge -t /bin/bash -l 13 | 14 | rem General - Name: 15 | name = Wscript.Arguments.Named("name") & ".lnk" 16 | set wshell = WScript.CreateObject("WScript.Shell") 17 | wscript.echo "Creating " & name 18 | set lnk = wshell.CreateShortcut(name) 19 | 20 | rem Target: 21 | rem lnk.TargetPath = Wscript.Arguments.Named("target") 22 | rem lnk.Arguments = Wscript.Arguments.Named("arguments") 23 | 24 | lnk.TargetPath = wshell.ExpandEnvironmentStrings("%target%") 25 | minttyargs = wshell.ExpandEnvironmentStrings("%minttyargs%") 26 | bridgeargs = wshell.ExpandEnvironmentStrings("%bridgeargs%") 27 | lnk.Arguments = minttyargs & " " & bridgeargs 28 | rem wscript.echo "minttyargs: " & minttyargs 29 | rem wscript.echo lnk.Arguments 30 | 31 | rem Start in: 32 | rem Working directory; Arguments.Named would take "/wdir:C:\..." parameters 33 | rem wdir = Wscript.Arguments.Named("wdir") 34 | rem Working directory; function ExpandEnvironmentStrings cannot pass empty 35 | wdir = wshell.ExpandEnvironmentStrings("%wdir%") 36 | if IsEmpty(wdir) then 37 | lnk.WorkingDirectory = "%USERPROFILE%" 38 | elseif wdir = "." then 39 | lnk.WorkingDirectory = "" 40 | else 41 | lnk.WorkingDirectory = wdir 42 | end if 43 | 44 | rem Icon: 45 | rem icon = Wscript.Arguments.Named("icon") 46 | rem rem iconoffset = Wscript.Arguments.Named("iconoffset") 47 | rem rem icon = icon & ", " & iconoffset 48 | icon = wshell.ExpandEnvironmentStrings("%icon%") 49 | rem wscript.echo "icon: " & icon 50 | lnk.IconLocation = icon 51 | rem rem lnk.IconLocation = "%LOCALAPPDATA%\lxss\bash.ico" 52 | rem lnk.IconLocation = "%LOCALAPPDATA%\wsltty\wsl.ico" 53 | 54 | rem Shorcut key: 55 | rem lnk.HotKey = "ALT+CTRL+W" 56 | 57 | rem Run: 58 | rem 1: Normal 7: Minimized 3: Maximized 59 | rem lnk.WindowStyle = 1 60 | min = Wscript.Arguments.Named("min") 61 | if min then 62 | lnk.WindowStyle = 7 63 | end if 64 | 65 | rem Comment: 66 | rem lnk.IconLocation = Wscript.Arguments.Named("desc") 67 | rem lnk.Description = "WSLtty" 68 | 69 | lnk.Save 70 | wscript.echo "Created " & name 71 | wscript.echo 72 | -------------------------------------------------------------------------------- /remove from context menu.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/remove from context menu.lnk -------------------------------------------------------------------------------- /tux.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/tux.ico -------------------------------------------------------------------------------- /tux1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/tux1.png -------------------------------------------------------------------------------- /ubuntu1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/ubuntu1.png -------------------------------------------------------------------------------- /uninstall.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%installdir%" == "" set installdir="%LOCALAPPDATA%\wsltty" 4 | call dequote installdir 5 | 6 | 7 | :shortcuts 8 | 9 | rem delete Start Menu Folder 10 | set smf="%APPDATA%\Microsoft\Windows\Start Menu\Programs\WSLtty" 11 | call dequote smf 12 | rmdir /S /Q "%smf%" 13 | 14 | 15 | :start menu 16 | 17 | cd /D "%installdir%" 18 | bin\dash.exe config-distros.sh -shortcuts-remove 19 | 20 | 21 | :explorer context menu 22 | 23 | cd /D "%installdir%" 24 | bin\dash.exe config-distros.sh -contextmenu-remove 25 | 26 | 27 | :undeploy 28 | 29 | cd /D "%installdir%" 30 | rem currently not removing software 31 | 32 | 33 | :end 34 | -------------------------------------------------------------------------------- /wsltty home & help.url: -------------------------------------------------------------------------------- 1 | [InternetShortcut] 2 | URL=https://github.com/mintty/wsltty -------------------------------------------------------------------------------- /wsltty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintty/wsltty/7074ff02b9437e1cc70e83da327211286cf61867/wsltty.png --------------------------------------------------------------------------------