Skip to content

Repository files navigation

l2w - Linux to Windows

CIPythonPlatformLicense

Translate and run Linux commands on Windows. Type l2w ls -la and it runs dir /a. That's it.


Why

I work in Linux a lot. When I am at my home PC I constantly find myself typing Linux commands out of habit and blanking on the Windows equivalent. At some point I figured it would be easier to just make the most common Linux commands work on Windows rather than keep googling "windows equivalent of ls".

Is this silly? Yes. Am I aware? Also yes. Am I lazy enough to build a whole translation table instead of just learning the commands? Apparently.


Install

One-liner (recommended) - open PowerShell and run:

iwr -useb https://raw.githubusercontent.com/Andrew-most-likely/l2w/master/install.ps1 | iex

This downloads the exe, installs it, generates all the command wrappers, and adds everything to your PATH. Open a new terminal when it finishes and type ls directly.

To uninstall:

iwr -useb https://raw.githubusercontent.com/Andrew-most-likely/l2w/master/uninstall.ps1 | iex

Manual install (no Python required):

Download l2w.exe from Releases, copy it to a folder in your PATH, then run:

l2w --install-wrappers

And add %USERPROFILE%\.l2w\bin to your PATH.

From source:

git clone https://github.com/Andrew-most-likely/l2w.git
cd l2w
pip install -e .

Usage

l2w <linux-command> [arguments]
l2w ls -la
l2w ls -a C:\Users
l2w cp file1.txt file2.txt
l2w cp -r src/ dest/
l2w mv old.txt new.txt
l2w rm file.txt
l2w rm -rf build/
l2w grep -i "error" app.log
l2w grep -r "TODO" .
l2w cat README.md
l2w head -n 20 file.txt
l2w tail -f app.log
l2w touch newfile.txt
l2w mkdir myfolder
l2w ps
l2w kill -9 1234
l2w --dry-run rm -rf dist/ # show translated command, do not execute
l2w --show-cmd cp -r src/ dst/ # show translated command then execute
l2w --list # list all supported commands
l2w --info grep # show translation details for a command

Supported commands

LinuxWindowsNotes
lsdir-a maps to /a
cpcopy / xcopyauto-switches to xcopy /e /i when -r is used
mvmove
rmdel / rmdirauto-switches to rmdir /s /q when -r is used
mkdirmkdir
rmdirrmdir /s /q
touchtype nul >
cattype
less / moremore
headGet-Content -TotalCount N
tailGet-Content -Tail N-f maps to -Wait
grepfindstr
finddir /s /b
pwdcd
echoecho
clearcls
pstasklist
killtaskkill /pid-9 maps to /f
killalltaskkill /im
pingping-c maps to -n
ifconfigipconfig
netstatnetstat
wgetcurl -O
curlcurl
ssh / scpssh / scpWindows 10+ OpenSSH
dfwmic logicaldisk ...
chmodicacls
chownicacls
sortsort
difffc
wcMeasure-Object
sleeptimeout /t
tartarWindows 10 build 17063+
zip / unzipCompress-Archive / Expand-Archive
whichwhere
whoamiwhoami
manhelp
envset
historydoskey /history
unamever
lnmklink

Run l2w --list for the full list.


Flags

FlagDescription
--dry-run, -nPrint translated command without executing
--show-cmd, -sPrint translated command then execute
--list, -lList all supported Linux commands
--info CMD, -i CMDShow translation details for a command
--config FILE, -c FILELoad custom command mappings from a JSON file

Custom commands

Add or override mappings without touching the source. Create config/commands.json (already included) or ~/.l2w/commands.json:

{
"commands": {
"ll": {
"windows": "dir /a",
"description": "Long listing alias",
"flag_map": {}
}
}
}

Then run:

l2w --config ~/.l2w/commands.json ll

Or place the file at ~/.l2w/commands.json and it will be picked up automatically.


Project structure

l2w/
├── l2w/
│ ├── commands.py # translation table (add new commands here)
│ ├── translator.py # translation logic
│ ├── executor.py # subprocess runner
│ ├── cli.py # argparse CLI
│ └── config_loader.py # JSON config support
├── config/
│ └── commands.json # user-editable overrides
├── tests/
│ └── test_translator.py
├── main.py # entry point
├── setup.py
├── build.bat # builds dist\l2w.exe via PyInstaller
└── requirements.txt

Adding a new command

Open l2w/commands.py and add an entry to COMMAND_MAP:

"mycommand": CommandDef(
windows="MyWindowsCmd.exe",
description="What it does",
flag_map={
"-v": "/verbose",
"-f": "/force",
},
notes="Optional caveats.",
),

For commands with complex argument handling, add a _handle_mycommand method to the Translator class in translator.py.


Running tests

pip install pytest
pytest tests/ -v

License

MIT - see LICENSE.

About

Translate and execute Linux commands on Windows - CLI tool + standalone .exe

Topics

Resources

Contributing

Stars

13 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages