目录
一. 问题
最近切换电脑, 调试问题输入命令,各个平台上输的手疼,想着有别名来代替简输的方式; 后续我就可以输入一些简短缩写来执行命令了,省去了不少调试和手工输入时间;
二. Windows Alias
1. 执行如下命令:
PS C:\Users\xxx> $profile
C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
2. 在C:\Users\xxx\Documents\WindowsPowerShell\ 目录下,新建Microsoft.PowerShell_profile.ps1 文件
输入如下命令:
FUNCTION gk { gitk --all }
FUNCTION pull { git pull origin }
FUNCTION push { git push origin }
FUNCTION prune { git remote prune origin }
FUNCTION hf { gitk HEAD..FETCH_HEAD }
FUNCTION dhf { gitk HEAD...FETCH_HEAD }
重启 PowerShell 终端, 即可;
三. Mac Alias
#
# 1. open file: /User/xxx/.bash_profile
# 2. $ source /User/xxx/.bash_profile
#
# alias list
alias gitk="sed -i .bak 's/zoomed/normal/g' ~/.config/git/gitk && /usr/local/bin/gitk"
alias gk="gitk --all&"
alias pull="git pull origin"
alias push="git push origin"
alias prune="git remote prune origin"
alias hf="gitk HEAD..FETCH_HEAD"
alias dhf="gitk HEAD...FETCH_HEAD"
alias hidden="defaults write com.apple.finder AppleShowAllFiles NO"
alias show="defaults write com.apple.finder AppleShowAllFiles YES"
执行如下命令, 使得别名设置生效:
# xxx 替换为你的机器上用户名
$ source /User/xxx/.bash_profile
四. 参考
- https://docs.microsoft.com/zh-cn/powershell/scripting/how-to-use-docs
- https://docs.microsoft.com/zh-cn/powershell/scripting/lang-spec/chapter-01
- https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_profiles