設定 Powershell 命令別名 (alias)

發布於 2026-08-14 00:00 194 字 1 min read

丁丁 avatar

丁丁

隨意寫寫,筆記記錄,以免忘記,後悔莫及

設定 Powershell 命令別名 (alias) 每次開啟 PowerShell 或終端機等 shell 環境時,都會執行一組腳本文件,用於初始化 session 可用的功能。在標準的 Ubuntu 發行版中,.bashrc 檔案就是其中之一。將別名指令加入 .bashrc 檔案中,即可讓開發者使用該別名。 Windows 同樣也有相同類似的設定 這時會印出你的 profile...

設定 Powershell 命令別名 (alias)

每次開啟 PowerShell 或終端機等 shell 環境時,都會執行一組腳本文件,用於初始化 session 可用的功能。在標準的 Ubuntu 發行版中,.bashrc 檔案就是其中之一。將別名指令加入 .bashrc 檔案中,即可讓開發者使用該別名。

Windows 同樣也有相同類似的設定

echo $profile

這時會印出你的 profile 路徑,你可以使用記事本或者 IDE 開啟編輯他

或者使用以下命令直接新增 alias 進 profile 中

echo "Set-Alias alias cmdlet" >> $profile

例如我要讓 ll 變成 ls 的別名 ( Linux 中 ls -al 的簡寫)

echo "Set-Alias ll ls" >> $profile

重開終端機後驗證看看是否有正確套用

© 2010 - 2026 丁丁 @ThanatosDi
Powered by theme astro-koharu · Inspired by Shoka