分享我的windows开发环境

在使用过 mac 和 window 做开发,我个人感觉还是 windows 开发效率高。
比如有 utool 这些工具,还是 powershell 加 docker,直接上天。

最终效果如图:

分享我的windows开发环境

安装 docker#

直接去官网下载安装

安装 php 环境#

推荐使用 https://github.com/yeszao/dnmp,
我自己也用 docker-compose 搞了个,不过没别人的方便。

安装 Scoop#

使用 scoop 来管理软件,以管理员身份运行 PowerShell, 执行

Set-ExecutionPolicy RemoteSigned -scope CurrentUser

然后执行安装命令

Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
# 或者
iwr -useb get.scoop.sh | iex

更换 scoop 源,依次执行

scoop config SCOOP_REPO https://gitee.com/squallliu/scoop
scoop update

scoop bucket add java https://hub.fastgit.org/ScoopInstaller/Java.git
scoop bucket add php https://hub.fastgit.org/ScoopInstaller/PHP.git
scoop bucket add versions https://hub.fastgit.org/ScoopInstaller/Versions.git
scoop bucket add nightlies https://hub.fastgit.org/ScoopInstaller/Nightlies.git
scoop bucket add extras https://hub.fastgit.org/lukesampson/scoop-extras.git

基本使用

scoop install [app]@[版本号] 

使用 conda 虚拟环境(python 可选)#

conda install -n root -c pscondaenvs pscondaenvs

安装 oh-my-posh 主题和 powershell 插件#

管理员权限打开 powershell,将 CurrentUserExecutionPolicy (执行权限) 从原来的 Undefined 更改成 RemoteSigned,同时信任来自 PSGallery 的所有模块:


Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

安装插件

# ls颜色插件
Install-Module -AllowClobber Get-ChildItemColor -Scope CurrentUser
# Docker插件
Install-Module DockerCompletion -Scope CurrentUser
# oh-my-posh主题
Install-Module oh-my-posh -Scope CurrentUser
# PSReadLine插件
Install-Module -Name PowerShellGet -Force
Install-Module -Name PSReadLine -AllowPrerelease -Force
# 类似zsh的jump插件
Install-Module ZLocation -Scope CurrentUser
#安装颜色插件
Install-Module -AllowClobber Get-ChildItemColor -Scope CurrentUser

安装字体

建议使用 JetBrainsMono 字体,下载地址:www.nerdfonts.com/font-downloads

我的配置#

需要更新配置文件 $PROFILE,类似于 Linux Bash 的.bashrc,输入:

code $PROFILE

在打开的文件中添加:

Import-Module posh-git
Import-Module DockerCompletion
Import-Module oh-my-posh
Import-Module PSReadLine
Import-Module Get-ChildItemColor

Set-PSReadLineKeyHandler -Key Tab -Function Complete
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete 

#Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
#Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -PredictionSource History

Set-PSReadLineOption -PredictionViewStyle ListView

Set-PoshPrompt  negligible

# function prompt { "Lunar $pwd" }
function cd... { Set-Location ..\.. }
Set-Alias dc docker-compose -Option "AllScope"

function which
{
    $results =New-Object System.Collections.Generic.List[System.Object];
    foreach ($command in $args)
    {
        $path = (Get-Command $command).Source
        if ($path)
        {
            $results.Add($path);
        }
    }
    return $results;
}
Set-Alias cat Get-Content -Option "AllScope"

#设置别名
function dp([string]$msg) { 
    if($msg -eq "a"){
        Write-Output "docker ps -a"
        docker ps -a
    }else{
        echo "docker ps "
        docker ps
    }
}

function dphp { 
     docker exec -it php /bin/sh
}


function build([string]$msg) { 
    Set-Location D:\Projects\docker_env
    docker-compose stop $msg 
    docker-compose build $msg
    docker-compose up -d $msg
}

function sh([string]$msg) { 
   docker exec -it $msg /bin/sh
}
function bash([string]$msg) { 
   docker exec -it $msg /bin/bash
}
function dr([string]$msg) { 
   docker restart $msg
}

# 3. 查看目录 ls & ll
function ListDirectory {
    (Get-ChildItem).Name
    Write-Host("")
}

# 设置ls和ll
$GetChildItemColorTable.File['Directory'] = "Red"
ForEach ($Exe in $GetChildItemColorExtensions.ExecutableList) {
    $GetChildItemColorTable.File[$Exe] = "Green"
}

Set-Alias -Name ll -Value Get-ChildItem
Set-Alias l Get-ChildItem -option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope

# 下面是conda的别名
function workon($name){
    activate $name
    # echo "切换到环境:"+[string]$name
}
function in($name){
    activate $name
    # echo "切换到环境:"+[string]$name
}
function out{
    deactivate
}

我使用的 windows terminal 主题:#

{
            "background": "#1B1B23",
            "black": "#000000",
            "blue": "#564D9B",
            "brightBlack": "#5D3225",
            "brightBlue": "#867AED",
            "brightCyan": "#EAEAEA",
            "brightGreen": "#29E620",
            "brightPurple": "#A05EEE",
            "brightRed": "#FF6388",
            "brightWhite": "#BFA3FF",
            "brightYellow": "#F08161",
            "cursorColor": "#A063EB",
            "cyan": "#808080",
            "foreground": "#877A9B",
            "green": "#37A415",
            "name": "Urple",
            "purple": "#6C3CA1",
            "red": "#B0425B",
            "selectionBackground": "#A063EB",
            "white": "#87799C",
            "yellow": "#AD5C42"
        }

到此就配置差不多了

本作品采用《CC 协议》,转载必须注明作者和本文链接
当它本可进取时,却故作谦卑; 在困难和容易之间,它选择了容易; 自由软弱,却把它认为是生命的坚韧; 侧身于生活的污泥中,虽不甘心,却又畏首畏尾。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 9
你看我吊吗啊

牛人。。

3年前 评论

MAC 开发效率不知道要比 Windows 开发高多少倍!

3年前 评论

只有我一个人觉得 windows 终端又丑又难用咩

3年前 评论
未定义 3年前
boolstone 3年前
幽弥狂

WIN 可以玩游戏呀,不过效率的话看个人认知了 不用非得争优劣

3年前 评论

用过 mac 还觉得 win 下开发效率高的也是少数

3年前 评论
陈怼怼 3年前

windows terminal 主题不错 copy 了 哈哈哈哈

3年前 评论