使用oh-my-posh等美化powershell

字体选择

  • 英文字体是支持PowerLine的DejaVuSansMono字体
  • 中文字体是文泉驿等宽微米黑字体
  • 并将终端字体设置为支持PowerLine的字体。
  • 建议设置颜色方案为Ubuntu
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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,725评论 0 3
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    wgl0419阅读 6,359评论 1 9
  • 关于Chocolatey   Chocolatey(中文译:巧克力味)是Windows平台下的一款包管理工具,类似...
    happyJared阅读 5,920评论 0 18
  • 俗话说:“春捂秋冻,不生杂病”。 “一场秋雨一场寒。”秋分过后,暑热几尽,凉风时至,天气渐寒。 “秋冻”是传统的养...
    沙飞创意阅读 273评论 0 0
  • 今天又有人问我十几了?我…… 我不过就是带着圆框眼镜。 经过换眼镜的事件我懂得,人只有不断地去尝试,不断的去拥有新...
    好大玲阅读 324评论 1 1