36

The terminal for Windows Subsystem for Linux (WSL) is fairly minimal. I have not used the terminal on Windows very much - I generally use Ubuntu or OSX - but I am surprised that the default terminal is so bare.

Is it possible to either:

  1. Connect a Windows terminal program to WSL or

  2. Launch the Ubuntu terminal program from WSL as an X window?

2

12 Answers 12

26

I personally do the latter: use VcXsrv as my X server in multiple windows mode, then launch the xfce4-terminal (because gnome-terminal had visual issues that I didn't care to try to learn how to fix), and suddenly I have a competent terminal with font and color support.

I found I needed to add these to my bashrc...

export DISPLAY="localhost:0"
export TERM=xterm-256color

Do the fix from this reddit for dbus:

sudo sed -i 's$<listen>.*</listen>$<listen>tcp:host=localhost,port=0</listen>$' /etc/dbus-1/session.conf

I also installed compiz and I use the cbwin project to run windows programs from my xfce4-terminal shell.

I am very happy with this setup and use NeoVim + lots of native linux plugins even though my "for-work" machine must be Windows. :)

It is also possible to start an SSH server in Bash-on-Linux-on-Windows and then connect to it, say from MinTTY like from Cygwin.

PS: to make launching xfce4-terminal painless and without the extra bash cmd window, I wrote a program that does nothing but start the bash process with arguments to start xfce4-terminal without a console window. I did this in C# - basically use arguments "UseShellExecute" false and "CreateNoWindow" true. I then pinned that to my taskbar and it's almost seemless.

EDIT: The answer with VBScript is brilliant. Here's that same script, but a JScript version...

WScript.CreateObject("WScript.Shell").run('bash.exe -l -c "DISPLAY=:0.0 xfce4-terminal"', 0, false);
4
  • 1
    Selected answer because its comprehensive and it helped me find stackoverflow.com/a/39188790; I realized updating MobaXterm to >9.0 got me a decent terminal for WSL. Sep 26 '16 at 4:31
  • If anyone is curious, here's the link to the reddit post from which the "fix from reddit" for dbus was lifted.
    – tel
    Jan 2 '18 at 22:00
  • @tel thanks! I actually did not know where that came from and have added the link...
    – aikeru
    Jan 4 '18 at 5:07
  • If the "visual issue you don't care to fix" is you can't see part of the prompt of directory or filenames the reason is they are dark blue. They aren't visible on the purple gnome-terminal background. The trick is to remap the color dark blue to turquoise and then it works fine. Jun 14 '18 at 2:45
22

It took a little while to figure out all the implied steps in the other answers, so here's a step by step summary:

  1. On Windows, install VcXsrv or XMing.
  2. In Bash for Windows, install the terminal: sudo apt-get install xfce4-terminal.
  3. Add export DISPLAY=:0 to your .bashrc. (Adding it to .profile or .bash_profile didn't work for me). This will allow you to start xfce4-terminal properly from bash, but is orthogonal to the command below.
  4. Run the following in a shortcut or in the Run prompt (as @OhJeez suggested in the comments):

    powershell -windowstyle hidden -Command "iex \"bash ~ -c 'DISPLAY=:0 xfce4-terminal'\" "
    

Other notes:

  • The ~ starts bash in your home directory, you can remove it to start in whatever directory the .vbs file is in, instead. So it's convenient to put it in C:\Users\foo, for example.
  • Note that XMing has to be running for the script to work; in order to start it automatically with Windows you can follow the instructions in this article.
  • Emacs 24 (included with Ubuntu 14.04) doesn't seem to work with XMing; I had to install a newer version as suggested in this post.
7
  • 1
    Thanks for your help. When i run the script, nothing seems to happen (Xming server is running). However, if I open bash and run xfce4-terminal it works fine. Furthermore, if I run bash -l -c xfce4-terminal from windows cmd, I get a warning Gtk-WARNING **: cannot open display: and nothing happens. I'm quite confused as I figured these commands should behave identically, any guesses?
    – rperryng
    Jul 10 '17 at 16:04
  • @rperryng yeah - I'm also trying to get a one-liner to open xfce without the ugly bash command prompt in between, but no luck yet.
    – Andrew Mao
    Jul 17 '17 at 20:21
  • 1
    Best solution for starting xfce4-terminal using shortcut. There is a flicker, but no window remains behind: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -Command "iex \"bash.exe ~ -c 'DISPLAY=:0 xfce4-terminal'\" " Another version which will start Xming if it's not running: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -Command "iex '& \"C:\Program Files (x86)\Xming\Xming.exe\" -multiwindow'; iex \"bash.exe ~ -c 'DISPLAY=:0 xfce4-terminal'\" "
    – OhJeez
    Jul 25 '17 at 21:45
  • @OhJeez nice, thanks for working out the intricacies of that command.
    – Andrew Mao
    Jul 28 '17 at 18:44
  • Workaround for high-resolution displays. If you have a 4k display, you will have blurry fonts in your terminal. To fix this you will need: 1. Use "VcXsrv Windows X Server" instead of Xing sourceforge.net/projects/vcxsrv 2. Run the xserver in compatibility mode. To do this you will need: click on VcXsrv shortcut with the right mouse button. Choose "Properties". On the "Compatibility" tab set checkbox against "Override high DPI scaling behavior..." and choose "Application" in the next dropdown. 3. Run xfce4-terminal and change font setting. Change font to a larger one.
    – koorchik
    Sep 30 '17 at 17:33
11

I created (and use) an open source terminal for Windows Subsystem for Linux (WSL) called wsl-terminal, it is based on mintty and wslbridge.

screenshot

10
  • Be careful with self promotion - it can look like spam. askubuntu.com/help/promotion
    – user513776
    Sep 20 '17 at 1:54
  • 6
    Self promotion is ok if you acknowledge it Sep 20 '17 at 2:16
  • 6
    And please, add some details about why wsl-terminal will provide a better terminal experience. Sep 20 '17 at 4:09
  • 2
    Thank you for sharing this. Your stuff already works better than the built-in terminal - at least it can deal with line wrapping on the command line a bit better. A CTRL-A to quickly go to the beginning of the command still fails though. I'm happy with people self promoting stuff like this. People should calm down.
    – EdH
    Dec 23 '17 at 15:41
  • 1
    Why don't you ask the 1000+ people who starred it on github @Cynplytholowazy ?
    – EdH
    Dec 29 '17 at 22:13
5

On a fresh Ubuntu install, I've just installed XMing (in Windows) then (in Ubuntu) xfce4-terminal, and after I export DISPLAY=:0, it worked.

To get rid of Windows's default console, this VBS script does the job:

WScript.CreateObject("WScript.Shell").run "bash -l -c xfce4-terminal", 0, True

(With $DISPLAY set in your .profile.)

edit: And to make the script pin'able, create a shortcut with target wscript "C:\path\to\thescript.vbs".

1
  • The VBS seems to work, however the terminal window is open and closed right after. How can I keep it running?
    – TCB13
    Apr 15 '17 at 22:04
4

On Windows:

  • Click on the upper left corner of the bash window.
  • In the menu that opens select 'Properties'
  • Set options that you want like font etc.(there is even an Ubuntu mono font!)
  • After setting properties they will be applied for current window. To set them as default click the upper left of the window and click defaults.
  • You can press Alt+Enter to toggle full screen mode.

I hope this helps.

1
  • I'd like to point out it has the same appearance / usage as Ubuntu's (Gnome's) terminal except it adds mouse support. ie You can click the column headings in htop Oct 7 '17 at 23:42
4

ConEmu works great! Just install it and start a new {bash} console. I added cd ~ to my .bashrc to have it default to starting in my home directory.

Good explanation: https://conemu.github.io/en/BashOnWindows.html

4

Today, you are suggested to use "Windows terminal" which is open sourced by Microsoft.

The official build can be obtained from Windows Store in mid June this year.

But you can also experience it using below preview version. https://github.com/yanglr/WindowsDevTools/blob/master/awosomeTerminal/WindowsTerminal_SelfSigned_x86_x64_arm64.7z

After installed, the running results are below:

pic1

pic2

pic3

pic4

2
2

Since the latest updates to Windows 10 (and WSL) everything seems to be working using "native" windows bash console. (And I am not talking about the (in)famous 1809 Windows update). This works even on Enterprise version at least for 1803 17134.345 build).

See the article at https://www.hanselman.com/blog/SettingUpAShinyDevelopmentEnvironmentWithinLinuxOnWindows10.aspx

A little caveat - to really use the bash console in Windows one should launch tmux - and everything will work as showed by Scott in his blog.

1
  • This is hilarious! "exec tmux" indeed solves all the Windows native "bash.exe" terminal issues (weird cut off lines after resizing). Oct 23 '18 at 22:22
2

Extraterm is more than just a terminal emulator. It provides a toolbox for working with your terminal and command line applications.

  • Features
  • Supports Linux and macOS, on Windows WSL, CMD, PowerShell and Cygwin
  • xterm compatible
  • Multiple tabs and panes, split and tiled any way you like
  • Show images in the terminal
  • Unicode support
  • Color emoji
  • Keyboard friendly “Command Palette”
  • Configurable key bindings
  • Keyboard based selections
  • Shell integration; can isolate and ‘frame’ command output. (bash, zsh and fish supported)
  • Easy uploads and downloads using the shell integration
  • Command output is editable in place. Multi-cursor editing
  • Previous command output can be used as input for new commands
  • Supports iTerm2 and TextMate themes
  • Text zoom
1
  • I am now using this terminal, as it has the features I really want. an easy way to switch between cmd, powershell, bash, fish etc.
    – nelaaro
    Jan 29 '19 at 8:46
1

Extending answers of aikeru and n.caillou as neither of their VBScript/JScript solutions worked right away for me.

Call WScript.CreateObject("WScript.Shell").Run("bash.exe -l -c 'DISPLAY=:0.0 xfce4-terminal --working-directory $HOME'", 0, True).

The script needs to be prepended by Call when using parenthesis in the run command, see here. Also the ticks needed to be the other way round. Moreover, an additional argument to xfce4-terminal will start the terminal in the user's home folder. Sorry if this was actually working JScript code, I have no idea about these scripting languages.

Saving this as a file vbscript.vbs and executing from a cmd prompt by

wscript vbscript.vbs

then opens a xfce4-terminal window (given XMing or alike is running) after 2 seconds delay. Turning this into a shortcut as suggested by n.caillou's works indeed and clicking the shortcut will automatically spawn a new xfce terminal window with some delay.

1

A terminal for a more modern age https://eugeny.github.io/terminus/

Terminus is a terminal heavily inspired by Hyper. It is, however, designed for people who need to get things done.

  • Runs on Windows, macOS and Linux
  • Theming and color schemes
  • Fully configurable shortcuts
  • Full Unicode support including double-width characters
  • Doesn't choke on fast-flowing outputs
  • Proper shell-like experience on Windows including tab completion (via Clink)
  • PowerShell (+Core), WSL (Bash on Windows), Git-Bash, Cygwin, Cmder and CMD support
  • Remembers your tabs
  • Integrated SSH client and connection manager
1

https://hyper.is/

  • It is based on electron which makes it easy to develop and extend using javascript.
  • It does not use the default windows console in any way.
  • It allows you to choose your backend shell bash, cmd, PowerShell.

    the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
    if left empty, your system's login shell will be used by default
    
    Windows
    - Make sure to use a full path if the binary name doesn't work
    - Remove `--login` in shellArgs
    
    Bash on Windows
    - Example: `C:\\Windows\\System32\\bash.exe`
    
    PowerShell on Windows
    - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
    shell: 'C:\\Windows\\System32\\bash.exe',enter code here
    

Very nice themes and plugins

plugins: [
    //"hyper-dracula"
    //"hyper-solarized-dark"
    "hyper-material-theme"
],

Using this guide I was able to get my WLS, bash working very nicely.

3
  • Thanks - looks like an interesting project but could you say more about the software and how to configure it for WSL? Jan 25 '19 at 3:21
  • 1
    @DavidLeBauer I hope that helps.
    – nelaaro
    Jan 25 '19 at 6:53
  • Hyper is super slow .
    – Mithril
    Apr 19 '19 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.