Windows Terminal(PowerShell)

  1. 前提条件
  • 安装支持Powerline的字体, 推荐JetBrains Mono, 安装了记得设置终端的字体
  • 安装Git
  • 将Powershell设置为可执行脚本,管理员身份运行powershell执行set-executionpolicy remotesigned
  1. 打开PowerShell,执行下面代码

     Install-Module posh-git -Scope CurrentUser
     Install-Module oh-my-posh -Scope CurrentUser
    
  2. 打开用户目录下的文档里的WindowsPowerShell文件夹,建立Microsoft.PowerShell_profile.ps1文本文件,注意后缀,文档里输入

    Import-Module posh-git
    Import-Module oh-my-posh
    Set-Theme PowerLine
    
  3. 重启PowerShell

  4. Windows Terminal设置

    {
        "theme": "dark",
        "$schema": "https://aka.ms/terminal-profiles-schema",
        "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
        "copyOnSelect": true,
        "copyFormatting": false,
        "profiles": {
            "defaults": {
                "fontFace": "JetBrains Mono",
                "fontSize": 11,
                "useAcrylic": true,
                "acrylicOpacity": 0.4,
                "padding": "2, 8, 8, 8",
                "colorScheme": "theme",
                "startingDirectory": "./"
            },
            "list": [
                {
                    "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                    "name": "Windows PowerShell",
                    "commandline": "powershell.exe",
                    "hidden": false
                },
                {
                    "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                    "name": "命令提示符",
                    "commandline": "cmd.exe",
                    "hidden": false
                },
                {
                    "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                    "hidden": false,
                    "name": "Azure Cloud Shell",
                    "source": "Windows.Terminal.Azure"
                },
                {
                    "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                    "hidden": false,
                    "name": "Ubuntu-20.04",
                    "source": "Windows.Terminal.Wsl"
                }
            ]
        },
        "schemes": [
            {
                "name": "theme",
                "black": "#adadad",
                "red": "#fc5256",
                "green": "#1a6406",
                "yellow": "#ccb444",
                "blue": "#437ee7",
                "purple": "#9d74b0",
                "cyan": "#248887",
                "white": "#2b05ff",
                "brightBlack": "#7da799",
                "brightRed": "#70e7fc",
                "brightGreen": "#98b61c",
                "brightYellow": "#ffff0b",
                "brightBlue": "#6c9ced",
                "brightPurple": "#fc7eff",
                "brightCyan": "#248887",
                "brightWhite": "#181818",
                "background": "#202020",
                "foreground": "#adadad"
            }
        ],
        "keybindings": [
            {
                "command": {
                    "action": "copy",
                    "singleLine": false
                },
                "keys": "ctrl+c"
            },
            {
                "command": "paste",
                "keys": "ctrl+v"
            },
            {
                "command": "find",
                "keys": "ctrl+shift+f"
            },
            {
                "command": {
                    "action": "splitPane",
                    "split": "auto",
                    "splitMode": "duplicate"
                },
                "keys": "alt+shift+d"
            }
        ]
    }
    

Cmder(powerline)

  1. 与Windows Terminal一样的前提条件(字体可以不用管)
  2. 下载cmder-powerline-prompt中的所有.lua文件,并放入cmder安装目录下的config目录下
  3. 修改cmder安装目录下的vendor目录下的clink.lua文件,将第51行附近的local lambda = "λ"改为local lambda = "$: "
  4. 修改cmder安装目录下的config目录下的powerline_core.lua文件,将113行附近的λ 修改为 $:

Linux(wsl) bash

  1.  sudo apt install powerline
    
  2. 设置字体

    字体下载: 推荐JetBrains Mono

    字体设置:

    • Ubuntu Desktop: 安装下载的字体
    • WSL: 在Windows Terminal中设置字体
  3. ~/.bashrc 中加入以下内容:

   POWERLINE_SCRIPT=/usr/share/powerline/bindings/bash/powerline.sh
    if [ -f $POWERLINE_SCRIPT ]; then
       source $POWERLINE_SCRIPT
    fi

Linux(wsl) zsh

自动配置脚本

wget https://gitee.com/VioletFreesia/scripts/raw/master/freesia.py
sudo python3 freesia.py -r zsh
zsh

手动修改

  1. 安装

    sudo apt -y install zsh git
    
  2. 使用oh-my-zsh配置

    git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
    cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    
  3. 修改主题

    ZSH_THEME="bira"
    ZSH_THEME="ys"
    ZSH_THEME="af-magic"
    ZSH_THEME="steeef"
    ZSH_THEME="theunraveler"
    # 更多主题在~/.oh-my-zsh/themes目录下
    
  4. 设置默认终端(wsl)

    chsh -s /bin/zsh
    

    Ubuntu Desktop 直接修改终端的首选项, 在命令栏勾选运行自定义命令而不是shell自定义命令输入zsh