使用oh-my-posh等美化powershell

字体选择

  • 英文字体是支持PowerLine的DejaVuSansMono字体
  • 中文字体是文泉驿等宽微米黑字体
  • 并将终端字体设置为支持PowerLine的字体。
  • 建议设置颜色方案为Ubuntu
使用oh-my-posh等美化powershell_第1张图片
conemu_settings.png

安装步骤

安装Chocolatey (windows的包管理器)

  1. 打开 Windows Powershell(管理员)
  2. PowerShell运行: Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  3. 安装完成后, 重新打开PowerShell输入choco -? 验证安装是否成功.

第2步输出如下:

PS C:\WINDOWS\system32> Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.11.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\cuika\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\cuika\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
 Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
警告: Not setting tab completion: Profile file does not exist at
'D:\Users\cuika\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

使用choco 安装终端 - ConEmu

PS C:\WINDOWS\system32> choco install ConEmu
Chocolatey v0.10.11
Installing the following packages:
ConEmu
By installing you accept licenses for the packages.
Progress: Downloading ConEmu 18.6.26.0... 100%

ConEmu v18.6.26.0 [Approved]
conemu package files install completed. Performing other installation steps.
The package ConEmu wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[N]o/[P]rint): Y

File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Error - hashes do not match. Actual value was 'CE2D7D5CA67792893531722D0FBB37EDA68147AFA80C662B3BC9572F5D2D8A1C'.
Downloading ConEmu 64 bit
  from 'https://github.com/Maximus5/ConEmu/releases/download/v18.06.26/ConEmuSetup.180626.exe'
Progress: 100% - Completed download of C:\Users\cuika\AppData\Local\Temp\chocolatey\ConEmu\18.6.26.0\ConEmuSetup.180626.exe (6.44 MB).
Download of ConEmuSetup.180626.exe (6.44 MB) completed.
Hashes match.
Installing ConEmu...
ConEmu has been installed.
  conemu may be able to be automatically uninstalled.
 The install of conemu was successful.
  Software installed as 'exe', install location is likely default.

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

安装 oh-my-posh

  1. 安装:

    Set-ExecutionPolicy Bypass
    Install-Module posh-git -Scope CurrentUser
    Install-Module oh-my-posh -Scope CurrentUser
    
  2. To enable the engine edit your PowerShell profile:

    if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
    notepad $PROFILE
    
  3. Append the following lines to your PowerShell profile:

    Import-Module posh-git
    Import-Module oh-my-posh
    Set-Theme Paradox
    
  4. 在PowerShell启动时加载这个模组了。类似于Linux Bash的.bashrc: Test-Path $profile

  5. 选择主题: Set-Theme paradox

    1. Agnoster
    2. Avit
    3. Darkblood
    4. Fish
    5. Honukai
    6. Paradox
    7. PowerLine
    8. robbyrussell
    9. Sorin
    10. tehrob

安装Gow - 可以执行Linux命令

choco install gow

https://github.com/bmatzelle/gow

你可能感兴趣的:(使用oh-my-posh等美化powershell)