-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i did what I wanted for myself - vim shim for WT (and it works!)
- Loading branch information
Showing
12 changed files
with
255 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,65 @@ | ||
# win-shim | ||
|
||
**<span style="color: red">THIS IS AN EARLY ALPHA!</span>** | ||
> THIS IS AN EARLY ALPHA! | ||
Lightweight and customisable shim executable for **Windows**. Shims supposed to work just like target executables they are shadowing. | ||
|
||
It's written in safe C++20. | ||
Lightweight and customisable shim executable for **Windows** written in safe modern `C++ 20`. | ||
|
||
## Features | ||
|
||
- Lightweight and Fast. Does not add to startup time, even for tiny utilities. | ||
- Self-sufficient and clean. Does not read config files or write anywhere. Does not need or require any external runtimes. | ||
- Mirrors: | ||
- [ ] Executable name. | ||
- [ ] Icon. | ||
- [ ] Version information. | ||
- [ ] Exit status (error code). | ||
- Extras | ||
- [x] Exit status (error code). | ||
- [x] Original version information. | ||
- [x] Original file details. | ||
- [x] Original application icon. | ||
- [ ] Application manifest. | ||
- Supports: | ||
- [x] Any command line, parametrised. | ||
- Extras (on the roadmap) | ||
- [ ] Limit registry access. | ||
- [ ] Limit filesystem access. | ||
- [ ] Limit amount of available RAM. | ||
- [ ] Change clock. | ||
- [ ] Freeze in background. | ||
|
||
## How to Use | ||
|
||
Download the latest release when ready. | ||
Download the latest release when ready (still in dev!). | ||
|
||
Originally this shim was written because I wanted to associate a file extension in Windows with [vim](https://www.vim.org/), but opened as a tab in [windows terminal](https://github.com/microsoft/terminal) instead of an ugly terminal popup window. WT [does allow it](https://docs.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows), however I would need to build a command line like: | ||
|
||
```bash | ||
wt -w 0 nt vim.exe <path_to_file> | ||
``` | ||
|
||
Unfortunately, you cannot associate a command line with an extension in Windows, only executable with an extension, so I though I'd build a shim executable for this. | ||
|
||
In order to achieve this, run `shmake` like following: | ||
|
||
```bash | ||
shmake.exe -c "wt -w 0 nt vim.exe %s" -o vimwt.exe -m "c:\scoop\apps\vim\3.2\vim.exe" | ||
``` | ||
|
||
which should generate a new executable `winwt.exe` that when called with an argument will open a tab in WT! `%s` is replaced by arguments passed to `wimwt.exe` when it executes. The last argument `-m` will also mirror vim application icon, version info and description so it looks just like vim everywhere. | ||
|
||
|
||
## Building | ||
|
||
As this is **Windows exclusive**, you need Visual Studio 2019 with Windows SDK installed. Normally I would use CMake, but is considerably harder (not impossible) to use when you need access to OS specific tools, especially native resources (which I utilise heavily to do the magic). | ||
As this is **Windows Exclusive**, you need Visual Studio 2019+ with Windows SDK installed. Normally I would use CMake, but it is considerably harder (not impossible) when you need access to OS specific tools, especially native resources (which I utilise heavily to do the magic). It is also very well integrated with `vcpkg`. | ||
|
||
`shmake` (but not shim) has dependency on: | ||
- `boost::program_options`. | ||
- `boost::program_options` to present you with a nice command line. | ||
- todo... | ||
|
||
All the dependencies are installed via [vcpkg](https://github.com/microsoft/vcpkg). | ||
|
||
``` | ||
vcpkg install boost-program-options:x64-windows boost-program-options:x64-windows-static | ||
``` | ||
|
||
`shim` does not have any dependencies and is kept as small and light as possible. | ||
`shim` **does not have any dependencies** and is kept as small and light as possible. | ||
|
||
### Extra Oddness | ||
|
||
`shmake` embeds `shim` inside it as a Windows native resource, so it's completely self-sufficient and can be distributed as a single `exe`. To do that, `smake`'s pre-build step copies `shim.exe` to `shim.bin` before build (as a pre-build step). Apparently `shim` is set as a project dependency of `shmake`, so it generates a full usable binary. | ||
`shmake` embeds `shim` inside it as a Windows native resource, so it's completely self-sufficient and can be distributed as a single `.exe`. To do that, `shmake`'s pre-build step copies `shim.exe` to `shim.bin` before build (as a pre-build step). Apparently `shim` is set as a project dependency of `shmake`, so it generates a full usable binary. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.