Notes
1.0.0
1.0.0
  • Introduction
  • Commands
    • cd
    • df
    • du
    • fc-cahe
    • ifconfig
    • ip
    • ls
    • lsb_release
    • mkdir
    • mksquashfs
    • mount
    • ping
    • pwd
    • rm
    • sar
    • sudo
  • Linux C
    • Preprocessor
    • Keywords
    • Kernel
      • Ftrace
      • Watchdog
  • Python
    • general
      • Decorator
      • Generator
      • Iterator
      • Lambda
    • Download
    • NIC
  • Network
    • Protocol
      • Link layer
      • IP
      • ARP
      • ICMP
    • Proxy
      • Cntlm
      • Proxychains4
      • ShadowSocks
    • Tools
      • iperf
      • tc
      • Wireshark
    • Apps
      • samba
      • tftp
  • Software
    • Atom
    • Chrome
    • Docker
    • Git
    • Gitbook
    • Hexo
    • Nodejs
    • Teraterm
    • Tex
    • Tmux
    • VIM
    • VSCode
  • Database
    • MongoDB
  • Web
    • CSS
    • LNMP
  • Tools
    • common
    • programming
  • Ubuntu
    • Add user
    • AWS EC2
    • FAQ
    • Installer
    • Shell
    • Shell scripts
    • Themes
    • VPS
  • Windows
    • PowerShell
    • CMD
    • FAQ
  • Aphorisms
  • Book List
  • Favorites
  • Appendix
    • ASCII
    • GSM
Powered by GitBook
On this page
  • 添加配置文件 PROFILE
  • 添加 alias
  • 添加函数

Was this helpful?

  1. Windows

PowerShell

添加配置文件 PROFILE

打开Powershell,输入指令:

mkdir C:\Users\<username>\Documents\WindowPowerShell\Microsoft.PowerShell_profile.ps1
$PROFILE="C:\Users\<username>\Documents\WindowPowerShell\Microsoft.PowerShell_profile.ps1"

PowerShell每次启动都会读取配置文件$PROFILE中的内容,类似于Linux中的 .profile 和 .bashrc.

添加 alias

和bash一样,PowerShell同样可以配置别名

Set-Alias <name> <value>  # 添加alias,不区分大小写
Set-Item alias:<name> <value>  # 功能与Set-Alias一致
Remove-Item alias:<name>  # 删除alias

值得注意的是,如果在命令行中添加alias,那么在下一次启动后就会失效,为了保证添加的alias永久有效,可以将其写入$PROFILE文件中。下次启动PowerShell时,它将自动获取文件中的别名并令其生效。

添加函数

funciton <name> {content}

函数同样可以放置在$PROFILE中。

PreviousWindowsNextCMD

Last updated 5 years ago

Was this helpful?