The $profile automatic variable stores the paths to the Powershell profiles that are available in the current session.
The $PROFILE variable stores the path to the "Current User, Current Host" profile. The other profiles are saved in note properties of the $PROFILE variable.
# 让ls和dir命令显示中文和颜色
alias ls='ls --show-control-chars --color'
alias dir='dir -N --color'
# 设置为中文环境,使提示成为中文
export LANG="zh_CN"
# 输出为中文编码
export OUTPUT_CHARSET="utf-8"
# 可以输入中文
set meta-flag on
set output-meta on
set convert-meta off
命令
生成唯一标识 guid [guid]::NewGuid()
设置代理
# powershell
$env:HTTP_PROXY="http://127.0.0.1:1080"
$env:HTTPS_PROXY="http://127.0.0.1:1080"
# cmd
set http_proxy=http://127.0.0.1:1080
探索 Powershell
Get-Verb
Returns a list of verbs that most commands adhere to.Get-command
retrieves a list of all commands installed on your machine.Get-Member
operates on object based output and is able to discover what object, properties and methods are available for a command.Get-Help
displays a help page describing various parts of a command.配置 powershell
安装 powershell
配置 windows terminal
安装 scoop - A command-line installer for Windows
安装 Winget - Install and manage applications
安装 git for windows - Offer a lightweight, native set of tools
安装
gcc
、neovim
powershell 配置文件 - about _profiles
The $PROFILE variable
The
$profile
automatic variable stores the paths to the Powershell profiles that are available in the current session.The
$PROFILE
variable stores the path to the "Current User, Current Host" profile. The other profiles are saved in note properties of the$PROFILE
variable.$profile
创建
$PROFILE.CurrentUserCurrentHost
文件 ,并添加. $env:USEPROFILE\.config\powershell\user_profile.ps1
内容,重新启动终端,这时配置文件已生效。安装
posh-git
和oh-my-posh
编辑
~/.config/powershell/user-profile.ps1
自定义 prompt
安装 nvm
安装 terminal icons
安装 z
安装 PSReadLine - autocompletion
How to use PSReadLine
To start using, just import the module:
Import-Module PSReadLine
To view the current key bindings:
Get-PSReadLineKeyHandler
To use Emacs key bindings, you can use:
Set-PSReadLineOption -EditMode Emacs
Specifies the source for PSReadLine to get predictive suggestions.
Set-PSReadLineOption -PredictionSource Hisory
Sets the style for the display of the predictive text. The default is InlineView.
Set-PSReadLineOption -PredictionViewStyle ListView
安装
fzf
PSFzfabout_Environment_Provider
The environment Environment provider lets you get, add, change, clear, delete environment variables and values in Powershell.
Windows and Powershell use Environment variables to store persistent information that affect system and process execution.
Unlike PowerShell variables, environment variables are not subject to scope constraints.
The Environment provider supports the following cmdlets.
about_Environment_Variables
Environment variables store information about the operating system environment.
The environment variables store data that is used by the operating system and other programs.
about_CommonParameters
描述可与任何 cmdlet 一起使用的参数。****
常见问题
Windows terminal 下 git bash 乱码问题
在相应的 git-for-windows 的安装路径文件
**\Git\etc\bash.bashrc
末尾添加命令
[guid]::NewGuid()
设置代理
技巧
Ctrl+shift+win+B
资源
https://www.powershellgallery.com/packages/PSFzf/2.0.0
https://www.powershellgallery.com/