PowerShell 是构建于 .NET 上基于任务的命令行 shell 和脚本语言。 PowerShell 可帮助系统管理员和高级用户快速自动执行用于管理操作系统(Linux、macOS 和 Windows)和流程的任务。
pwsh docs 地址
pwsh docs
pwsh vs bash
Start-Job -ScriptBlock {hexo s} |
hexo s & |
get-job remove-job Receive-Job stop-job wait-job |
unknow |
[command1] ; [command2] |
[command1] ; [command2] |
try{[command1] ; [command2]} catch{$error[0];break} |
[command1] && [command2] |
[command1] \| [command2] |
[command1] \| [command2] |
[command1] > 1.txt |
[command1] > 1.txt |
[command1] >> 1.txt |
[command1] >> 1.txt |
my profile
普通用户下执行$profile
以获取启动脚本路径powershell 需要在管理员权限下执行 set-executionpolicy remotesigned 以使用自建脚本
,等价~/.bashrc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
function hexocgd { hexo clean; hexo g; hexo d; } function hexogd { hexo g; hexo d; }
function editpspre { code $PROFILE } function cddesktop { Set-Location C:\Users\HZJ\Desktop; }
$startUpPath = 'C:\Users\HZJ\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'; function echoStartUpPath { $startUpPath; }
function hosts { code "%SystemRoot%\system32\drivers\etc\hosts"; } function updatehosts { ipconfig /flushdns; } function restartWsl { net stop LxssManager; net start LxssManager; }
function zwhichis() { cmd /c where $command }
function Simple-Date() { Get-Date -Format 'yyyy-MM-dd HH:mm:ss' }
set-alias sDate Simple-Date set-alias grep select-string
Import-Module posh-git Import-Module oh-my-posh
Set-Theme Darkblood
Set-PSReadlineKeyHandler -Key Tab -Function Complete Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
function godocstart() { godoc -http=:6060 ; Start-Process "http://127.0.0.1:6060/doc" }
function godocshow() { Start-Process "http://127.0.0.1:6060/doc" }
function ll() { Get-ChildItem }
function gitsetp() { git config --global http.proxy http://127.0.0.1:11000 git config --global https.proxy http://127.0.0.1:11000 }
function gitunsetp() { git config --global --unset http.proxy git config --global --unset https.proxy }
function setp() { $env:HTTPS_PROXY = "http://127.0.0.1:11000" $env:HTTP_PROXY = "http://127.0.0.1:11000" }
function unsetp() { Remove-Item Env:http_proxy Remove-Item Env:https_proxy }
function work() { Set-Location 'C:\Users\HZJ\Desktop\work' } function workspace { Set-Location D:\WorkSpace\; } function cddr ($ps) { switch ($ps) { 'n' { "准备进入nginx容器" docker exec -it nginx_lumen //bin//sh } 'p' { "准备进入php容器" docker exec -it php_lumen //bin//sh } default { "容器不存在" } } }
function xqssh($ps) { switch ($ps) { '1' { "准备进入st" + $ps ssh httpd@172.17.224.7 } '2' { "准备进入st" + $ps ssh httpd@172.17.225.9 } '3' { "准备进入st" + $ps ssh httpd@172.17.226.7 } Default { "准备进入st1" ssh httpd@172.17.224.7 } } }
function wblog() { code C:\Users\HZJ\Desktop\blog }
function cdworktool{ Set-Location D:\WorkSpace\simple\laravel8 }
function gitpushall($message = "update all") { git add . ; git commit -m '"'$message'"' ; git push }
function gitcpush($message = "update all"){ git commit -m '"'$message'"' ; git push }
function adbscreencap(){ $time = Get-Date -Format 'yyyyMMddHHmmssfff' $filePath = '/sdcard/'+$time+'.png' C:\Users\HZJ\AppData\Local\Android\Sdk\platform-tools\adb.exe shell screencap -p $filePath C:\Users\HZJ\AppData\Local\Android\Sdk\platform-tools\adb.exe pull $filePath } function echoadbpath(){ "C:\Users\HZJ\AppData\Local\Android\Sdk\platform-tools\adb.exe" }
|
other
1 2 3 4 5 6 7 8 9 10 11 12
| :: 端口映射操作 :: sql ssh -fNg -L [映射端口]:[远程ip]:[远程端口] [username]@[ip] :: redis ssh -fNg -L 6379:10.0.2.222:6379 hanzhijie@10.0.2.222 :: memcache ssh -fNg -L 11211:10.0.2.221:11211 hanzhijie@10.0.2.222
:: order-app-start start /b php -S localhost:8081 C:\Users\username\Desktop\xz\xz_app\public\index.php :: order-facade-start start /b php -S localhost:8082 C:\Users\username\Desktop\xz\xz_facade\public\index.php
|