台式机编程环境配置

配置清单

  • shell
    • windows最新控制台 (powershell 7 + Terminal)
    • psh插件管理
    • terminal 美化 (oh-my-posh)
    • 字体
  • IDE
    • vscode
    • 插件库
    • python环境 (anaconda miniconda)
    • C++环境 (mingw)
  • 远程环境
    • ssh
    • 远程文件传输
  • 文档
    • typora
    • picgo
    • obsidian

安装细节

VSCode

没啥特别的安装步骤,直接从官网上下载安装程序就行,安装完之后用vsc自带的sync工具同步插件就好
这里可能需要单独配置的内容有:

  1. VScode终端的字体(通过设置菜单直接设置)

  2. ctrl+滚轮缩放字体大小

Terminal

win11安装时附带Terminal(之前用的是从应用商店下载的预览版,感觉区别不大)
这里需要配置的有:

  1. 字体配置 (NF)
  2. 安装7.0版本的powershell
  3. 如果有ssh需求的也可以配置
  4. 分栏快捷键设置(切换成类tmux的设置)
{
    "command":
    {
        "action": "splitPane",
        "split": "vertical",
        "splitMode": "duplicate"
    },
    "keys": "ctrl+["
},
{
    "command":
    {
        "action": "splitPane",
        "split": "horizontal",
        "splitMode": "duplicate"
    },
    "keys": "ctrl+]"
},
{
    "command":
    {
        "action": "closePane",
    },
    "keys": "ctrl+w"
}
  1. 简单的美化 (改透明度)

Powshell插件

Terminal自带PSReadLine插件工具,需要简单配置一下

基础配置如下

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\star.omp.json" | Invoke-Expression

Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

Set-PSReadLineKeyHandler -Chord '"',"'" `
                         -BriefDescription SmartInsertQuote `
                         -LongDescription "Insert paired quotes if not already on a quote" `
                         -ScriptBlock {
    param($key, $arg)

    $line = $null
    $cursor = $null
    [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)

    if ($line.Length -gt $cursor -and $line[$cursor] -eq $key.KeyChar) {
        # Just move the cursor
        [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1)
    }
    else {
        # Insert matching quotes, move cursor to be in between the quotes
        [Microsoft.PowerShell.PSConsoleReadLine]::Insert("$($key.KeyChar)" * 2)
        [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
        [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor - 1)
    }
}

# EditMode
# Set-PSReadLineOption -EditMode Emacs

Set-PSReadLineOption -ShowToolTips

# enable git tab completion
# Import-Module

# enable gui completion
# Set-PSReadlineKeyHandler -Key Tab -ScriptBlock { Invoke-GuiCompletion }


function make-link ($target, $link) {
    New-Item $link -ItemType SymbolicLink  -Target $target
}

scoop
这是一款powershell包管理工具

$env:SCOOP='D:\Software\Scoop'
[Environment]::SetEnvironmentVariable('SCOOP', $env:SCOOP, 'User')
$env:SCOOP_GLOBAL='D:\Software\Scoop\GlobalScoopApps' 
[Environment]::SetEnvironmentVariable('SCOOP_GLOBAL', $env:SCOOP_GLOBAL, 'Machine')

iwr -useb get.scoop.sh | iex


# cnpmjs 配置镜像
scoop config SCOOP_REPO https://github.com.cnpmjs.org/ScoopInstaller/Scoop/

添加scoop源

scoop bucket add main 'https://github.com/ScoopInstaller/Main'
scoop bucket add extras 'https://github.com/ScoopInstaller/scoop-extras'
scoop bucket add versions 'https://github.com/ScoopInstaller/Versions'
scoop bucket add jetbrains 'https://github.com/Ash258/Scoop-JetBrains'
scoop bucket add java 'https://github.com/ScoopInstaller/Java'
scoop bucket add dorado https://github.com/chawyehsu/dorado
scoop bucket add scoopet https://github.com/ivaquero/scoopet

oh-my-posh

新版本的omp的安装方式建议参考官网的方式配置

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression

这样配置的启动时间快很多

C++环境配置

这次不打算搞MSVC,打算用gcc作为编译器,而windows上gcc需要mingw64提供windows必要的环境,因此通常说mingw就是gcc+mingw环境

首先需要安装MSYS2

scoop install msys2

用msys2自带的包管理器pacman安装mingw64,之后输入msys2进入环境

pacman -S mingw-w64-x86_64-toolchain

gcc执行文件加入到环境变量中


$env:MINGW64='D:\Software\Scoop\apps\msys2\current\mingw64\bin' 
[Environment]::SetEnvironmentVariable('MINGW64', $env:MINGW64,'Machine')

参考