♻️
UbuntuにPowerShell入れるメモ
環境
- Ubuntu 18.04
手順
PowerShell 入れる
sh
# Download the Microsoft repository GPG keys
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt update
# Enable the "universe" repositories
sudo add-apt-repository universe
# Install PowerShell
sudo apt install powershell
# Start PowerShell
pwsh
ログインシェルをPowerShellにする
sh
chsh -s /usr/bin/pwsh
posh-git 入れる
powershell
Install-Module posh-git
$PROFILE 編集
powershell
vim $PROFILE
~/.config/powershell/Microsoft.PowerShell_profile.ps1
# プロンプト設定 (お好みで変えて下さい)
function prompt {
$tmp = $LASTEXITCODE
$GitPromptSettings.EnableWindowTitle = "$(git rev-parse --git-common-dir | Split-Path -Parent | Split-Path -Leaf) "
$path = git rev-parse --show-prefix
if ($null -eq $path) {
$path = $ExecutionContext.SessionState.Path.CurrentLocation.Path
} else {
$path = ':' + $path -replace '/$', ''
}
Write-Host $path -NoNewline
Write-VcsStatus
"$('>' * ($NestedPromptLevel + 1)) "
$LASTEXITCODE = $tmp
}
# posh-git
Import-Module posh-git
$GitPromptSettings.EnableStashStatus = $true
# ~/bin をPATHに追加
$env:PATH += ":/home/$env:USER/bin"
# エイリアス (適当にいろいろ入れてね)
function exec() {
Start-Process -Wait @args
}
New-Alias eval Invoke-Expression
New-Alias g git
# ssh-agent
Start-SshAgent
Discussion