闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境

闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境_第1张图片

闪亮蔚蓝

While I was getting Ruby on Rails to work nicely under Ubuntu on Windows 10 I took the opportunity to set up my *nix bash environment, which was largely using defaults. Yes, I know I can use zsh or fish or other shells. Yes, I know I can use emacs and screen, but I am using Vim and tmux. Fight me. Anyway, once my post was done, I starting messing around with open source .NET Core on Linux (it runs on Windows, Mac, and Linux, but here I'm running on Linux on Windows. #Inception) and tweeted a pic of my desktop.

当我让Ruby on Rails在Windows 10的Ubuntu下正常运行时,我趁机设置了* nix bash环境,该环境主要使用默认设置。 是的,我知道我可以使用zsh或fish或其他shell。 是的,我知道我可以使用emacs和screen,但是我正在使用Vim和tmux。 和我战斗。 无论如何,一旦我的帖子写完,我就开始在Linux上运行开源.NET Core(它可以在Windows,Mac和Linux上运行,但在这里我可以在WindowsLinux上运行。#Inception)并发了一张图我的桌面。

By the way, I feel totally vindicated by all the interest in "text mode" given my 2004 blog post "Windows is completely missing the TextMode boat." ;)'

顺便说一句,考虑到我2004年的博文“ Windows完全缺少TextMode之船”,我对“文本模式”的所有兴趣完全证明了这一点。 ;)'

Also, for those of you who are DEEPLY NOT INTERESTED in the command line, that's cool. You can stop reading now. Totally OK. I also use Visual Studio AND Visual Studio Code. Sometimes I click and mouse and sometimes I tap and type. There is room for us all.

另外,对于那些对命令行不感兴趣的人来说,这很酷。 您现在可以停止阅读。 完全可以。 我也使用Visual Studio和Visual Studio代码。 有时我单击并单击鼠标,有时我单击并键入。 我们所有人都有空间。

WHAT IS ALL THIS LINUX ON WINDOWS STUFF? Here's a FAQ on the Bash/Windows Subsystem for Linux/Ubuntu on Windows/Snowball in Hell and some detailed Release Notes. Yes, it's real, and it's spectacular. Can't read that much text? Here's a video I did on Ubuntu on Windows 10.

WINDOWS STUFF上的所有这些LINUX是什么? 这是《地狱》中Windows / Snowball上用于Linux / Ubuntu的Bash / Windows子系统上的常见问题,以及一些详细的发行说明。 是的,它是真实的,而且非常壮观。 看不到那么多文字? 这是我在Windows 10上的Ubuntu上做的视频。

A number of people asked me how they could set up their WSL (Windows Subsystem for Linux) installs to be something like this, so here's what I did. Note that will I've been using *nix on and off for 20+ years, I am by no means an expert. I am, and have been, Permanently Intermediate in my skills. I do not dream in RegEx, and I am offended that others can bust out an awk script without googling.

许多人问我如何设置WSL(Linux的Windows子系统)安装,就像这样,所以这就是我所做的。 请注意,我会一直使用* nix开启和关闭20多年,我绝不是专家。 我曾经并且一直是我技能的永久中级。 我没有在RegEx上做梦,而且我很生气,其他人可以不使用谷歌搜索就破坏awk脚本。

闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境_第2张图片

So there's a few things going on in this screenshot.

因此,此屏幕快照中发生了一些事情。

  • Running .NET Core on Linux (on Windows 10)

    在Linux上运行.NET Core(在Windows 10上)
  • Cool VIM theme with >256 colors

    酷炫的VIM主题> 256种颜色
  • Norton Midnight Commander in the corner (thanks Miguel)

    角落里的 诺顿 午夜指挥官(感谢米格尔)

  • Desqview-esque tmux splitter (with mouse support)

    Desqview式tmux分离器(具有鼠标支持)
  • Some hotkey remapping, git prompt, completion

    一些热键重新映射,git提示,完成
  • Ubuntu Mono font

    Ubuntu Mono字体
  • Nice directory colors (DIRCOLORS/LS_COLORS)

    不错的目录颜色(DIRCOLORS / LS_COLORS)

Let's break them down one at a time. And, again, your mileage may vary, no warranty express or implied, any of this may destroy your world, you read this on a blog. Linux is infinitely configurable and the only constant is that my configuration rocks and yours sucks. Until I see something in yours that I can steal.

让我们一次分解它们。 同样,您的里程可能会有所不同,没有明示或暗示的担保,任何此类行为都可能破坏您的世界,请在博客上阅读。 Linux是无限可配置的,唯一不变的是我的配置摇摇欲坠,而您的配置很糟糕。 直到我发现您可以偷的东西。

在Linux上运行.NET Core(在Windows 10上) (Running .NET Core on Linux (on Windows 10) )

Since Linux on Windows 10 is (today) Ubuntu, you can install .NET Core within it just like any Linux. Here's the Ubuntu instructions for .NET Core's SDK. You may have Ubuntu 14.04 or 16.04 (you can upgrade your Linux on Windows if you like). Make sure you know what you're running by doing a:

由于Windows 10上Linux是(今天)Ubuntu,因此您可以像安装任何Linux一样在其中安装.NET Core。 这是.NET Core SDK的Ubuntu说明。 您可能拥有Ubuntu 14.04或16.04(如果愿意,可以在Windows上升级Linux)。 通过执行以下操作,确保您知道自己在运行什么:

~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
~ $

If you're not on 16.04 you can easily remove and reinstall the whole subsystem with these commands at cmd.exe (note the /full is serious and torches the Linux filesystem):

如果您不在16.04上,则可以使用以下命令轻松地在cmd.exe上删除并重新安装整个子系统(请注意/ full严重并破坏了Linux文件系统):

> lxrun /uninstall /full
> lxrun /install

Or if you want you can run this within bash (will take longer but maintain settings).

或者,如果您愿意,可以在bash中运行它(将花费更长的时间,但会保留设置)。

NOTE that you'll need Windows 10 Creators Edition build 16163 or greater to run Ubuntu 16.04. Type "winver" to check your build.

请注意,您需要Windows 10 Creators Edition版本16163或更高版本才能运行Ubuntu 16.04。 键入“ winver”以检查您的构建。

sudo do-release-upgrade

Know what Ubuntu your Windows 10 has when you install .NET Core within it. The other thing to remember is that now you have two .NET Cores, one Windows and one Ubuntu, on the same (kinda) machine. Since the file systems are separated it's not a big deal. I do my development work within Ubuntu on /mnt/d/github (which is a Windows drive). It's OK for the Linux subsystem to edit files in Linux or Windows, but don't "reach into" the Linux file system from Windows.

当您在其中安装.NET Core时,请了解Windows 10所具有的Ubuntu。 要记住的另一件事是,现在您在同一台(kinda)计算机上具有两个.NET Core,一个Windows和一个Ubuntu。 由于文件系统是分开的,所以没什么大不了的。 我在/ mnt / d / github(这是Windows驱动器)上的Ubuntu中进行开发工作。 Linux子系统可以在Linux或Windows中编辑文件,但是不要从Windows“进入” Linux文件系统。

酷炫Vim主题,具有> 256色 (Cool Vim theme with >256 colors )

That Vim theme is gruvbox and I installed it like this. Thanks to Rich Turner for turning me on to this theme.

Vim的主题是gruvbox ,我这样安装了它。 感谢Rich Turner为我开启了这个主题。

$ cd ~/
$ mkdir .vim
$ cd .vim
$ mkdir colors
$ cd colors
$ curl -O https://raw.githubusercontent.com/morhetz/gruvbox/master/colors/gruvbox.vim
$ cd ~/
$ vim .vimrc

Paste the following (hit ‘i’ for insert and then right click/paste)

粘贴以下内容(单击“ i”进行插入,然后右键单击/粘贴)

set number
syntax enable
set background=dark
colorscheme gruvbox
set mouse=a

if &term =~ '256color'
" disable Background Color Erase (BCE) so that color schemes
" render properly when inside 256-color tmux and GNU screen.
" see also http://snk.tuxfamily.org/log/vim-256color-bce.html
set t_ut=
endif

Then save and exit with Esc, :wq (write and quit). There's a ton of themes out there, so try some for yourself!

然后保存并使用Esc :wq退出(写入并退出)。 那里有很多主题,所以请自己尝试一下!

角落里的 诺顿 午夜指挥官(感谢米格尔) ( Norton Midnight Commander in the corner (thanks Miguel) )

Midnight Commander is a wonderful Norton Commander clone that Miguel de Icaza started, that's licensed as part of GNU. I installed it via apt, as I would any Ubuntu software.

Midnight Commander是Miguel de Icaza创建的一个出色的Norton Commander克隆版本,已作为GNU的一部分获得许可。 我通过apt来安装它,就像安装任何Ubuntu软件一样。

$ sudo apt-get install mc

There's mouse support within the Windows conhost (console host) that bash runs within, so you'll even get mouse support within Midnight Commander!

在其中运行bash的Windows conhost(控制台主机)中有鼠标支持,因此您甚至可以在Midnight Commander中获得鼠标支持!

Great stuff.

好东西。

Desqview式tmux分离器(具有鼠标支持) (Desqview-esque tmux splitter (with mouse support) )

Tmux is a terminal multiplexer. It's a text-mode windowing environment within which you can run multiple programs. Even better, you can "detach" from a running session and reattached from elsewhere. Because of this, folks love using tmux on servers where they can ssh in, set up an environment, detach, and reattach from elsewhere.

Tmux是终端多路复用器。 这是一个文本模式的窗口环境,您可以在其中运行多个程序。 更好的是,您可以从正在运行的会话中“分离”并从其他位置重新附加。 因此,人们喜欢在服务器上使用tmux,他们可以在其中插入,建立环境,分离并与其他地方重新连接。

NOTE: The Windows Subsystem for Linux shuts down all background processes when the last console exits. So you can detach and attach tmux sessions happily, but just make sure you don't close every console on your machine.

注意:当最后一个控制台退出时,Windows Linux子系统将关闭所有后台进程。 因此,您可以愉快地分离和附加tmux会话,但只需确保不要关闭计算机上的每个控制台即可。

Here's a nice animated gif of me moving the splitter on tmux on Windows. YES I KNOW YOU CAN USE THE KEYBOARD BUT THIS GIF IS COOL.

这是我在Windows的tmux上移动分离器的一个很好的动画gif。 是的,我知道您可以使用键盘,但此GIF很酷。

闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境_第3张图片

一些热键重新映射,git提示,完成 (Some hotkey remapping, git prompt, completion )

I am still learning tmux but here's my .tmux.conf. I've made a few common changes to make the hotkey creation of windows easier.

我仍在学习tmux,但这是我的.tmux.conf。 我进行了一些常规更改,以简化Windows的热键创建。

#remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# split panes using | and -
bind | split-window -h
bind _ split-window -v
unbind '"'
unbind %
bind k confirm kill-window
bind K confirm kill-server
bind < resize-pane -L 1
bind > resize-pane -R 1
bind - resize-pane -D 1
bind + resize-pane -U 1
bind r source-file ~/.tmux.conf

# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse on
set -g default-terminal "screen-256color"

I'm using the default Ubuntu .bashrc that includes a check for dircolors (more on this below) but I added this for git-completion.sh and a git prompt, as well as these two alias. I like being able to type "desktop" to jump to my Windows Desktop. And the -x on Midnight Commander helps the mouse support.

我正在使用默认的Ubuntu .bashrc,其中包括对dircolors的检查(请参见下文),但我为git-completion.sh和git提示以及这两个别名添加了它。 我喜欢能够键入“桌面”以跳到Windows桌面。 Midnight Commander上的-x可以帮助鼠标支持。

alias desktop="cd /mnt/c/Users/scott/Desktop"
alias mc="mc -x"
export CLICOLOR=1
source ~/.git-completion.sh
PS1='\[\033[37m\]\W\[\033[0m\]$(__git_ps1 " (\[\033[35m\]%s\[\033[0m\])") \$ '
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"

Git Completion can be installed with:

Git Completion可以通过以下方式安装:

sudo apt-get install git bash-completion

Ubuntu Mono字体 (Ubuntu Mono font )

I really like the Ubuntu Mono font, and I like the way it looks when running Ubuntu under Windows. You can download the Ubuntu Font Family free. Right click the downloaded TTF files and right click and "Install," or drag them into C:\windows\fonts. Then click the upper left corner of any Bash console window and change your font to Ubuntu Mono.

我真的很喜欢Ubuntu Mono字体,而且我喜欢Windows下运行Ubuntu时的外观。 您可以免费下载Ubuntu Font Family 。 右键单击下载的TTF文件,然后右键单击“安装”,或将它们拖到C:\ windows \ fonts中。 然后单击任何Bash控制台窗口的左上角,并将字体更改为Ubuntu Mono。

闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境_第4张图片

精美的目录颜色(DIRCOLORS / LS_COLORS)' (Nice directory colors (DIRCOLORS/LS_COLORS)')

If you have a black command prompt background, then default colors for directories will be dark blue on black, which sucks. Fortunately you can get .dircolors files from all over the wep, or set the LS_COLORS (make sure to search for LS_COLORS for Linux, not the other, different LSCOLORS on Mac) environment variable.

如果您有黑色的命令提示符背景,则目录的默认颜色将是黑色的深蓝色,这很烂。 幸运的是,您可以从wep各处获取.dircolors文件,或者设置LS_COLORS (确保在Linux上搜索LS_COLORS,在Mac上不要搜索其他LSCOLORS)环境变量。

I ended up with "dircolors-solarized" from here, downloaded it with wget or curl and put it in ~. Then confirm this is in your .bashrc (it likely is already)

我从这里得到了“ dircolors-solarized” ,用wget或curl下载了它,并将其放入〜。 然后确认这在您的.bashrc中(可能已经存在)

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

Download whatever .dircolors file makes you happy (make sure the filename ends up as ".dircolors," so you may need to cp yoursourcefile ~/.dircolors and then restart your console.

下载使您满意的任何.dircolors文件(请确保文件名结尾为“ .dircolors”,因此您可能需要cp yoursourcefile〜/ .dircolors,然后重新启动控制台。

Make a big difference for me, and as I mention, it's totally, gloriously, maddeningly configurable.

对我有很大的影响,正如我提到的,它是完全,光荣的,令人疯狂的可配置的。

闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境_第5张图片

Leave YOUR Linux on Windows tips in the comments!

在注释中留下您在Windows上Linux提示!

翻译自: https://www.hanselman.com/blog/setting-up-a-shiny-development-environment-within-linux-on-windows-10

闪亮蔚蓝

你可能感兴趣的:(闪亮蔚蓝_在Windows 10上Linux中设置闪亮的开发环境)