Git Product home page Git Product logo

wsl-terminal's Introduction

wsl-terminal

A terminal emulator for Windows Subsystem for Linux (WSL), based on mintty, fatty and wslbridge2.

All emojis designed by OpenMoji – the open-source emoji and icon project. License: CC BY-SA 4.0

中文页面(The Chinese README is no longer maintained)

Screenshot

screenshot

More screenshots here.

Usage

  1. Make sure you have 7z installed. On Ubuntu run: sudo apt install p7zip-full, on Archlinux: run pacman -S p7zip

  2. Change the directory to the folder where you want to install wsl-terminal to.

Make sure to install wsl-terminal in a the windows filesystem and not in the wsl filesistem. The installation folder needs to be on a local NTFS volume.

  • Option 1: If you're in cmd.exe run:
wsl bash -c "$(wget https://raw.githubusercontent.com/mskyaxl/wsl-terminal/master/scripts/install.sh -qO -)"
  • Option 2: If you're in wsl already run
bash -c "$(wget https://raw.githubusercontent.com/mskyaxl/wsl-terminal/master/scripts/install.sh -qO -)"

If you want to install the tabbed version you have to add a -t as parameter as shown bellow

bash -c "$(wget https://raw.githubusercontent.com/mskyaxl/wsl-terminal/master/scripts/install.sh -qO -)" '' -t
  1. Run open-wsl.exe to open a WSL terminal in current directory.

  2. Run tools/1-add-open-wsl-terminal-here-menu.js (help) to add a Open wsl-terminal Here context menu to explorer.exe (Run tools/1-remove-open-wsl-terminal-here-menu.js to remove it). If you are using Total Commander, Use wsl-terminal with Total Commander may help you.

  3. run-wsl-file.exe can run any .sh (or any others like .py .pl) script files in wsl-terminal, support Open With context menu in explorer.exe.

  4. vim.exe can open any files with vim (in wsl-terminal), support Open With context menu in explorer.exe. vim.exe can be renamed to emacs.exe nvim.exe nano.exe ... to open files in emacs nvim nano ....

Keyboard shortcuts

key function
Alt + Enter Fullscreen
Alt + F2 New window
Alt + F3 Search text
Ctrl + [Shift] + Tab Switch window
Ctrl + = + - 0 Zoom
Ctrl + Click Open URL or dir/file under the cursor
Ctrl + Right Click Open context menu

Bind wsl-terminal to a hotkey.

Params

open-wsl

Usage: open-wsl [OPTION]...
  -a: activate an existing wsl-terminal window.
      if use_tmux=1, attach the running tmux session.
  -l: start a login shell and cd to $HOME (doesn't work with use_tmux=1).
  -c command: run command (e.g. -c "echo a b; echo c; cat").
  -e commands: run commands (e.g. -e echo a b; echo c; cat).
  -C dir: change directory to a WSL dir (e.g. /home/username).
  -W dir: change directory to a Windows dir (e.g. c:\Users\username).
  -d distro: switch distros.
  -b "options": pass additional options to wslbridge.
  -B "options": pass additional options to mintty.
  -h: show help.

For -B and -b, see also mintty params and wslbridge2 params.

cmdtool (run it in WSL)

Usage: cmdtool [OPTION]...
  wcmd: run Windows programs with cmd.exe /c.
  wstart: run Windows programs with cmd.exe /c start.
  wstartex file|url: like wstart, but use WSL file path.
  update: check the latest wsl-terminal version, and upgrade it.
  killall: kill all WSL processes.
  install dash: install Cygwin dash (for debugging).
  install busybox: install Cygwin busybox (for debugging).

Tools

Files in tools directory:

filename function
1-add-open-wsl-terminal-here-menu.js Add Open wsl-terminal Here context menu to explorer.exe.
1-remove-open-wsl-terminal-here-menu.js Remove Open wsl-terminal Here context menu.
2-add-wsl-terminal-dir-to-path.js Add wsl-terminal directory to Path environment variable.
2-remove-wsl-terminal-dir-from-path.js Remove wsl-terminal directory from Path environment variable.
3-write-distro-to-config-file.js Write distro guids to etc/wsl-terminal.conf.
4-create-start-menu-shortcut.js Create a start menu shortcut to open-wsl -C ~.
4-create-start-menu-shortcut-login-shell.js Create a start menu shortcut to open-wsl -l.
4-remove-all-start-menu-shortcuts.js Remove all wsl-terminal start menu shortcuts.
5-add-open-with-vim-menu.js Add Open with vim in wsl-terminal context menu.
5-remove-open-with-vim-menu.js Remove Open with vim in wsl-terminal context menu.
6-set-default-shell.bat Set shell in etc/wsl-terminal.conf to the default shell in WSL.

Double click any .js file to run it. If it was open by any editor, open it with Microsoft (R) Windows Based Script Host, or open a cmd.exe in tools directory and run wscript xxx.js.

Configuration files

etc/wsl-terminal.conf is wsl-terminal config file.

[config]
title="my title"
shell=/bin/bash
use_tmux=0
;icon=
;distro=

etc/themes/* are theme files, use themes.

etc/minttyrc is mintty config file, mintty tips.

Upgrade

Open open-wsl.exe in wsl-terminal directory, run ./cmdtool update to check the latest wsl-terminal version and upgrade it. If the download speed is too slow, you can download wsl-terminal-v{version}.7z from releases with other tools, and put it into wsl-terminal directory, then run ./cmdtool update.

wget and 7z commands are needed (Ubuntu: apt install wget p7zip-full, Archlinux: pacman -S wget p7zip) .

Config files won't be overridden, etc/wsl-terminal.conf and etc/minttyrc will be placed to etc/wsl-terminal.conf.pacnew and etc/minttyrc.pacnew. Some .bak files will be left in bin, because they are running, those files will be removed after the next upgrading.

Use tmux

  1. Install tmux in WSL.
  2. Set use_tmux=1 in etc/wsl-terminal.conf. And set attach_tmux_locally=1 if the version number is less than 0.8.1.
  3. Add these lines to ~/.bashrc (shell=/bin/bash in config) or ~/.zshrc (shell=/bin/zsh in config):
[[ -z "$TMUX" && -n "$USE_TMUX" ]] && {
    [[ -n "$ATTACH_ONLY" ]] && {
        tmux a 2>/dev/null || {
            cd && exec tmux
        }
        exit
    }

    tmux new-window -c "$PWD" 2>/dev/null && exec tmux a
    exec tmux
}

If you're using fish then update your '~/.config/fish/config.fish' (shell=/bin/fish in config) with

if [ -z "$TMUX" ]; and [ -n "$USE_TMUX" ]
    if [ -n "$ATTACH_ONLY" ]
        if not tmux a 2>/dev/null
            cd; and exec tmux
        end
        exit
    end

    tmux new-window -c "$PWD" 2>/dev/null; and exec tmux a
    exec tmux
end

Then open-wsl will use tmux.

Switch distros

Use open-wsl -d distro to switch distros:

# list all distros
> wslconfig /l
Legacy (Default)
Ubuntu

# use Ubuntu (will run wslconfig /s Ubuntu before mintty)
> open-wsl -d Ubuntu

# Ubuntu is the default distro now
> wslconfig /l
Ubuntu (Default)
kali-linux

Or set distro in wsl-terminal.conf (Won't change the default distro).

Run tools/3-write-distro-to-config-file.js (help), then a msgbox will show the result:

result has been written to ..\etc\wsl-terminal.conf:

;distro=kali-linux

;distro=Ubuntu

remove the ; before distro to use the distro.

If you want to pass the distro_guid to open-wsl in cmdline:


# pass the distro guid to wslbridge
> open-wsl -b "-d Ubuntu"

Links

FAQ

Issues

Releases

Wiki

Build

Prerequisites

  • Install WSL and make sure wget tar xz gzip p7zip are available (Ubuntu: run apt install wget tar xz-utils gzip p7zip-full, Archlinux: run pacman -S wget tar xz gzip p7zip) are installed in WSL.
  • for the tabbed version: cygwin x64 with the following packages installed gcc-g++, make, w32api-headers (for compiling fatty)

Build steps

  • clone the repo in WSL(to maintain the linux EOL characters) but on windows drive eg (/mnt/c/Users/<userName>/work/wsl-terminal)

  • use build.sh to build with the appropiate parameters.

    ➜  wsl-terminal git:(master) scripts/build.sh -h
    Usage:
        build.sh -h                 Display this help message.
        build.sh -a                 Builds wsl-terminal and wsl-terminal-tabbed.
        build.sh -t                 Builds only wsl-terminal-tabbed(cygwin is required).
        build.sh                    Builds only wsl-terminal.
    

Roadmap

  1. Bug fixing
  2. add x11 support

License

MIT

wsl-terminal's People

Contributors

adnoc avatar blu3r4y avatar dgadelha avatar goreliu avatar kehao-chen avatar lks90 avatar michaelmai2000 avatar milly avatar mskyaxl avatar perlence avatar quizr avatar thiagotalma avatar zchrissirhcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wsl-terminal's Issues

New tmux window on opening wsl-terminal.

I've enabled use_tmux option and attach_tmux_locally and it works great aparat from fact that every time I reopen wsl-terminal windows it creates additional windows in my current tmux sessions.

Is this an intended behavior? Can I do something so it won't open new window in tmux on startup?

Hangs changing fonts

Tried with powerline version of Inconsolata-G and Droid Sans.
It hangs on Options | Text | Apply click.

Latest wsl-terminal on Win 10 Pro

minttyrc too specific

For a general-use distribution, I would suggest not to include your personal preferences in a minttyrc file for deployment.

add-open-wsl-here-menu.js syntax error

Hi there, when I run tools/add-open-wsl-here-menu.js as per the readme, I get the following error:

tools/add-open-wsl-here-menu.js: line 1: syntax error near unexpected token `('
tools/add-open-wsl-here-menu.js: line 1: `var WshShell = new ActiveXObject("WScript.Shell");'

Theme is not applied on startup

Hi, I have not been able to apply a theme to the terminal on startup. Instead I have to manually apply the theme in Options > Looks > Theme > Save every time I open a new window. Although the theme name is auto-populated in the Theme field, it does not actually get applied. Here is my minttyrc file:

BoldAsFont=-1
FontHeight=10
Font=Consolas
Scrollbar=none
Term=xterm-256color
CursorType=line
AllowBlinking=yes
Locale=en_US
Charset=UTF-8
BellType=0
BellTaskbar=no
Printer=
Language=@
ClicksPlaceCursor=yes
Columns=170
Rows=48
ThemeFile=base16-seti-ui.minttyrc

To launch wsl-terminal I am using a shortcut pinned to the Taskbar with C:\path\to\wsl-terminal\open-wsl.exe -l in the Target field. I have also tried appending the contents of the theme file to minttyrc, but that does not seem to work either. Any ideas? Thank you.

Edit: I made a mistake. I think there was a setting saved somewhere that conflicted with my theme, which made it appear slightly different than expected.

多标签

我觉得现在就差标签功能了,不知道后续版本有打算支持么?

Using -l parameter doesn't execute .bashrc file

I'm trying to create a shortcut that will open the terminal in my WSL home directory, so I'm using the -l switch. However, when I use this switch, the terminal doesn't seem to execute my .bashrc file.

Started with the -l parameter:
image

Started without the -l parameter:
image

Support for clickable links

We often get links in our terminals (stuff from tooling, build output, irc, whatever).

Having links rendered to be clickable would be a nice addition.

Add Icon to context menu

Hey there!

I thought it would be nice to have a Icon in the context menu. Problem is I don't know how the javascript/registry entry stuff works.

I manually added the Icon Registry entry with the value of the open-wsl.exe to my registry, here is a little preview of how it looks.

context menu entry with icon

Fails to launch in Window 10 Insider preview 14986

I'm seeing behavior on my laptop (Surface book 1 running insider build 14986.rs_prerelease.161202-1928) where upon trying to launch, it hangs explorer, and never launches. I'm not seeing this behavior on my desktop, running the current windows 10 build (14393.693)

I don't get an error message or anything, it just never launches. I am able to open the normal WSL command line and it runs fine.

开启tmux,启动wsl-terminal闪退

遇到过两次,都是开机后再启动wsl-terminal的时候窗口一闪就没了.关闭use_tmux再启动正常.之后再修改启动tmux也正常.
wsl-terminal 0.8.5
tmux 2.6

Can not save my option after I clicked Apply instead of Save

Hi, this is the first time I use this terminal. I applied the option I modified in option menu and reopened the terminal, NOTHING had been changed. And I found that Apply can not save my option and I should use the Save button.
This may be a bug. I hope this terminal can be better.

Cannot run open-wsl.exe under some conditions relating to space in path

This error can be reproduced by the following steps:

  1. Create a folder which name contains space, such as C:\folder name\
  2. Put whole wsl-terminal folder under the folder created in step 1
  3. Create a file named the same as the first half (before first space) of the folder name from step 1 and put them under the same path, such as C:\folder
  4. Try to run C:\folder name\wsl-terminal\open-wsl.exe and you will get the error

Starts but closes immediately...

If I execute open-wsl.exe (even as administrator), it starts showing a window for very few ms, then close immediately.
The lsb_release shows:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty

Can't open etc/wsl-terminal.conf for writing

I'm not sure what's going on, whether it's weird permissions or my machine, but for whatever reason I can't edit etc/wsl-terminal. Vim says it "Can't open file for writing", and Notepad++ says "Please check if this file is opened in another program". Does wsl-terminal start some daemon that holds these files open?

Can I use wsl-terminal directly?

Windows' recently update--WSL is just awesome
I had run into some color-theme issues until I found this one
It support full 256-color and abundant color theme!

However, i found it automatically open some tools such as wslbridge
image
Is it possible to luach shell directly like the upper one which is lunched by default icon ?

Any way to "pin to taskbar"?

First of all thanks for this great terminal!
The only "problem" I have is that I didn't find a way to pin it to the Windows 10 Taskbar.
I did use the utility to pin it to start and it works nicely, but when I try to pin it to the Taskber either it doesn't work or when I click, it opens in another icon.

Any ideas on how to do it? Thanks!

Is true colors supported?

I've read that mintty on cygwin supports true colors, does wsl-terminal supports it? If so, how to set it? At the moment I have 256 colors.

multi tab support

I hope use multi tab in a Window, instead of open many terminal with many Window.

I tried Tmux, but failed.

Default shell

Seems that latest Windows 10 update includes wsl.exe that does actually honor the default shell used on the ubunty subsystem that I set via the chsh -s $(which zsh) command. Is this a feature that can or should be explored?
Thanks

not plug-and-play; doesn't start

Thanks for making such a package at all; however, it has some non-standard preconditions.
ahk is not a standard file extension and not installed here, so it does not work.

"Open WSL here" context menu appears on recycle bin

Tested on Windows 10 Build 14393.693 (production) and Windows 10 Build 15025.1000 (Insider) with wsl-terminal 0.6.6

By default after setting up the "Open WSL here" context menu entry, it attaches itself to the Recycle bin context menu. Clicking it opens the WSL Terminal to the desktop.

Sometimes tmux hangs

Set use_tmux=1 in etc/wsl-terminal.conf, open 3 windows in tmux, close wsl-terminal, open wsl-terminal, and close again. About 5-10 times, tmux hangs.

Strace result:

...
clock_gettime(CLOCK_MONOTONIC, {13821, 354105000}) = 0
gettimeofday({1471612303, 78251}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {13821, 354232000}) = 0
gettimeofday({1471612303, 78251}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {13821, 354357000}) = 0
gettimeofday({1471612303, 78251}, NULL) = 0
epoll_wait(3, [], 32, 0)                = 0
clock_gettime(CLOCK_MONOTONIC, {13821, 354613000}) = 0
gettimeofday({1471612303, 78251}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {13821, 354815000}) = 0
gettimeofday({1471612303, 78251}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {13821, 354966000}) = 0
gettimeofday({1471612303, 78251}, NULL) = 0
epoll_wait(3, [], 32, 0)                = 0
...

How to avoid mouse scrolling?

I have a touchpad by which I trigger mouse scrolling by accident with some frequency. On Linux I can configure tmux with the following to disable mouse scrolling:

# Avoid scrolling through command history and what not.
set -ga terminal-overrides ',xterm*:smcup@:rmcup@'

It has no effect on wsl-terminal. Is there a setting to disable mouse scrolling on mintty, or simply disable mouse at all?

tmux resurrect

Hey,

Any ideas how can we hook things up with https://github.com/tmux-plugins/tmux-resurrect? I was trying to play with it a bit, but the main issue was that #{pane_current_path} is always empty while exporting tmux current windows/panes state. I was trying wsl-terminal + tmux 2.1 up to 2.4 and various changes in save.sh script but the result (despite people telling their success stories on OSX and Linux) was exactly the same. So i figured, perhaps it has something to do with the way it works under wsl-terminal? I think this project deserves a way to store and restore opened windows and this tmux plugin seems to be pretty good choice for it.

https://github.com/tmux-plugins/tmux-resurrect/blob/master/scripts/save.sh#L44 - this is the place responsible for storing current PATH for pane.

Also, the way i was running tmux (use_tmux=0/1 and running tmux by hand or by terminal - also with attach_tmux_locally) has no effect.

Any ideas? Any hints?

wcmd/wrun doesn't work.

I just use open-wsl.exe to launch bash and everything is pretty good.

Then I set use_cbwin=1, run sudo ./install_cbwin.sh to install wcmd/wrun/wstart. But when I run wcmd ping 127.0.0.1, nothing happens, and I have to press <C-c> to exit.

The same wrun is.

But wstart works.

If I use outbash.exe or wslbridge.exe to launch bash, all of them works.

What can I do to fix it?

Blank Terminal on Launch

Not sure what I'm missing here.

If I launch open-wsl.exe via explorer or run command, I get nothing but a cursor and no functionality.
If I launch from cmd prompt, it works as expected. Any insights?

EDIT: Success condition is actually running open-wsl as admin.

midnight commander shell window does not work

wsl-terminal: v0.8.3
mintty: 2.7.9
midnight commander: 4.8.15 (apt-get installed)
Windows 10: build 1703 (wsl / ubuntu)

When shell window opened (Ctrl-O) no shell prompt. Any key causes return to normal (blue panel) window.

Expected: shell

For comparison, cygwin64, mintty 2.7.4, and mc 4.8.18 do not have this issue.

Cannot open multiple mintty instances

Hi

I would like to be able to run multiple tmux sessions in multiple instances of mintty with wsl-terminal. Whenever I try to run open-wsl a second time either from the start menu shortcut or the app directory itself, I get the error:

Failed to run '/bin/bash': No such file or directory

And when I press a key the mintty windows.

I can open multiple mintty windows with other versions of mintty I have on my PC.

Any idea how I could get this to work?

[suggestion] add tabs

support tabs in the terminal similar to other terminal programs. I have not found a good solution for this.

Tries to open a back door

On installation I found it tried to set up a back door to the internet, some place. My inplace software blocked it. Why does it need a back door to the internet?

Can not display italic font

I try a lot of different configurations but still can't display a italic font in wsl-terminal. (when it can be displayed well with cygwin using mintty). Is this a particular case ?

[Feature] Presets based on mainly terminals

In the menus, will be great show presets based on main terminals and/or distros.

Example: at the first app start, popup a window with big buttons with logos of Ubuntu, Mint, Gnome and KDE. Based on this option, all settings will be set.

High cp usage

If I use WSL as standalone bash.exe, I get an average of 0.00 cpu percentage usage for conhost process. But If I try using bash (mintty?) inside wsl-terminal, I get an average of 24 cpu percentage usage per conhost process.

I have WSL Build 15007 and usually keep my ubuntu up to date. I just installed wsl-terminal 0.6.6

Here is with standalone bash.exe: (I am running three instances of bash.exe and even running a mongod server service)
image

Here is the same environment with wsl-terminal:
image

There it reports ~60% of constant CPU usage and I am only running one tab (bash) inside wsl-terminal, no services running on WSL and no other difference with the previous scenario.

Related issue on BashOnWindows: microsoft/WSL#1618

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.