{"id":14069735,"url":"https://github.com/leongrdic/wsl-alias","last_synced_at":"2025-10-27T12:05:19.319Z","repository":{"id":115590708,"uuid":"105128545","full_name":"leongrdic/wsl-alias","owner":"leongrdic","description":"create aliases for Linux commands in Windows command line (for WSL)","archived":false,"fork":false,"pushed_at":"2019-12-21T15:29:24.000Z","size":29,"stargazers_count":77,"open_issues_count":1,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-01T00:46:49.112Z","etag":null,"topics":["alias","aliases","bash","batch","linux","proxy","shell","ubuntu","windows","windows-subsystem-linux","wsl"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leongrdic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-09-28T09:21:42.000Z","updated_at":"2024-10-24T13:39:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0ed63ae-52be-4c27-a01e-09d4d0a7e99f","html_url":"https://github.com/leongrdic/wsl-alias","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leongrdic%2Fwsl-alias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leongrdic%2Fwsl-alias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leongrdic%2Fwsl-alias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leongrdic%2Fwsl-alias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leongrdic","download_url":"https://codeload.github.com/leongrdic/wsl-alias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228102185,"owners_count":17869792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alias","aliases","bash","batch","linux","proxy","shell","ubuntu","windows","windows-subsystem-linux","wsl"],"created_at":"2024-08-13T07:07:10.797Z","updated_at":"2025-10-27T12:05:14.285Z","avatar_url":"https://github.com/leongrdic.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# wsl-alias\n\nCreate aliases of Linux commands to access them from Windows command line or PowerShell!\n\nThis is a simple Windows batch script and bash command wrapper that allows you to pass commands to your WSL (Windows Subsystem for Linux) from Windows and adds a few sweet features like aliases and automatic mounting. What that means is you can install PHP, NodeJS, etc. in your WSL and use them from Windows!\n\nIf you still don't understand what that means, here are a few examples (all commands are executed from the Windows PowerShell):\n```\n\u003e cd C:\\Users\\User\\Documents\\repo\n\u003e b git commit -m \"commit message\"\n```\n\n```\n\u003e b apt-get install php-cli\n\u003e b wsl-alias add php php\n\u003e php -v\n```\n\n```\n\u003e cd Z:\\Projects\n\u003e b pwd\n/mnt/z/Projects\n```\n\n## Features\n\nHere's a quick overview of the features:\n-   pass commands to WSL without escaping them\n-   use Linux programs and scripts as if they were installed in Windows\n-   translates your current Windows path into the WSL path (for all drives)\n-   translates Windows paths in command arguments to WSL paths (relative and absolute) - thanks to [hustlahusky](https://github.com/hustlahusky)\n-   a single file with environment variables and code that will be loaded when executing commands or entering an interactive shell (solves [this](https://github.com/Microsoft/BashOnWindows/issues/219))\n-   automatically mount the drives that WSL doesn't - with different filesystems and even network drives (solves [this](https://superuser.com/a/1133984/413987))\n\n## Installation\n\nFirst of all, make sure you're running the Spring Creators update or newer and have installed Ubuntu on Windows 10 (or another distribution) from the [Windows Store](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). Next, start up wsl (using the command `bash` or `wsl`) on Windows 10 as the default user and run this command:\n```\nbash \u003c(curl -o- https://raw.githubusercontent.com/leongrdic/wsl-alias/v2.4/install.sh)\n```\nThe install script will clone this repository and put it into your home directory with right permissions and help you configure access to the `mount` command withougt a password.\nYou will be asked to choose the __default alias__ (command that will actually call your default shell). You can just leave it empty, which sets it to `b`.\n\nFinally you will get a message from the installer with a path that you should copy and put into your user environment variable on Windows. ([here](https://stackoverflow.com/a/44272417/1830738)'s a beautiful tutorial)\n\nAll you have to do now is open the command line or PowerShell and start typing:\n```\nb          # opens an interactive shell\nb [cmd]    # executes the command cmd in WSL\n```\nnote: if you chose a different default alias, use it instead of `b`\n\n## Aliases\nAliases allow you to call Linux commands from Windows. They pass all the arguments and the current directory and allow you to benefit of the auto-mount feature.\n\nUse the command `wsl-alias` inside WSL as following:\n```\nwsl-alias list                       # lists all aliases\nwsl-alias add [name] [command]       # adds a new alias\nwsl-alias remove [name]              # removes an existing alias\n```\nMake sure you don't remove the default alias (the one you specified during installation) or you might have to reinstall `wsl-alias`. This is because the command `wsl-alias` only works when you're accessing WSL using one of the existing aliases.\n\n## `env.sh` script\nYou can use the shell script `~/.wsl-alias/env.sh` to define environment variables, mount drives or run other scripts every time you use any of your aliases. For example you can include the _`nvm` initialization code_ or `ssh-agent` setup there.\n\nThis script also directly serves as a replacement for `.bashrc`, of course only for user-added commands and variables. (note they will only be accessible when using one of your aliases)\n\nThe `$wslalias_interactive` variable provides a way to find out if the user has passed any arguments with the _default alias_\n```\n$wslalias_interactive == \"0\"     # a command was passed\n$wslalias_interactive == \"1\"     # no commands passed\n```\nThis might be useful if, for example, you want to set up a new `ssh-agent` only if the shell is interactive.\n\nSetting an environment variable:\n```\nexport variable=\"value\"\n```\n\n## Auto mounting\nWhen you call any alias, your current directory is taken from Windows and translated into a WSL path (e.g. `/mnt/c/Users`). Windows already does this but not for all drives. That's where `wsl-alias` comes in - we check if the drive isn't already mounted and do it without prompting you for the root password!\n\nBecause WSL only lives as long as its last background process, your drive could get unmounted after each command (if there are no background wsl processes running). That's why we provide you with a way to always mount your drive, whether you're entering the interactive shell (using the default alias) or just running a command - add the following line to the `env.sh` file:\n```\nsudo mount -o uid=[USER_UID],gid=[USER_GID] -t drvfs [DRIVE_LETTER]: /mnt/[DRIVE_LETTER]\n```\n\n### Avoid mounting drives on each alias run\n\nYou can use an approach like [this one](https://emil.fi/bashwin) (props to that guy) to make WSL always run in background so that you always have a background wsl process running.\n\n## Escaping commands\n### PowerShell\n```\nb echo \"a \\\"\"b\\\"\" c\"     # prints: a \"b\" c\nb echo \"a 'b' c\"         # prints: a 'b' c\nb echo 'a \\\"b\\\" c'       # prints: a \"b\" c\nb echo 'a ''b'' c'       # prints: a 'b' c\n```\n\n### cmd\n```\nb echo \"a \\\"b\\\" c\"       # prints: a \"b\" c\nb echo \"a 'b' c\"       # prints: a 'b' c\nb echo 'a \"b\" c'       # prints: a \"b\" c\n# not possible to escape single quotes inside single quotes\n```\n\nPowerShell is recommended because of better syntax support, but both should do for basic functionality.\n\n## Limitations\nUnfortunately you can't pass all symbols through `wsl-alias`. Those include redirectors (`\u003e`, `\u003e\u003e`, `\u003c`, etc.), separators (`;`, `\u0026\u0026`, etc.). But you can always open an interactive shell and execute commands just like you would on Linux!\n\n## Troubleshooting\nThe most common problems...\n1.  are you running Windows 10 version 1803 A.K.A. Spring Creators Update (build 17046 or later)?\n1.  have you updated the PATH environment variable in Windows?\n1.  did you install `wsl-alias` as the default WSL user?\n1.  did you accidentally remove the default alias?\n1.  is `bash` installed in WSL? (while bash is required, `wsl-alias` can work with any other default shell)\n\n## Reinstallation or uninstallation\nIf you want to reinstall `wsl-alias` simply run the installer command again.\n\nTo uninstall just remove the `~/.wsl-alias` directory like so:\n```\nrm -rf ~/.wsl-alias\n```\n\n## Security\n`wsl-alias` sets the permission of the `/mnt` directory to 777, so you can create mountpoints for new drives without explicit permission. This shouldn't be considered a security risk, except if you have some important data in that directory protected with the Linux permissions.\n\nAn optional entry to `/etc/sudoers` can be set while installing to allow `wsl-alias` to allow mounting a drive (access to the `mount` and `umount` binaries) without typing a password.\n\nIf you find any security related bugs, please open an issue or better yet contact me personally. I do not guarantee that this code is 100% secure and it should be used at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleongrdic%2Fwsl-alias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleongrdic%2Fwsl-alias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleongrdic%2Fwsl-alias/lists"}