Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Last active May 17, 2019 06:40
Show Gist options
  • Save takekazuomi/d3e80d0be4c7fb7db77194c3a10cf87d to your computer and use it in GitHub Desktop.
Save takekazuomi/d3e80d0be4c7fb7db77194c3a10cf87d to your computer and use it in GitHub Desktop.
if ($host.Name -eq 'ConsoleHost')
{
if(-not (Get-Module PSReadline))
{
Install-Package PSReadline -Force
}
Import-Module PSReadline
Set-PSReadlineOption -EditMode Emacs
Set-PSReadlineKeyHandler -Key Ctrl+R -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key Ctrl+S -Function HistorySearchForward
}
function Prompt{
"$ "
}
$PSDefaultParameterValues["Out-File:Encoding"] = "Ascii"
@(
"C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe",
"C:\Program Files (x86)\Microsoft VS Code\Code.exe"
) | % {
if (Test-Path $_) {
$alias = ((Split-Path $_ -Leaf) -split '\.')[0].ToLower()
set-alias $alias $_
}}
# for dotnet command complete
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
# dotnet suggest shell start
$availableToComplete = (dotnet-suggest list) | Out-String
$availableToCompleteArray = $availableToComplete.Split([Environment]::NewLine, [System.StringSplitOptions]::RemoveEmptyEntries)
Register-ArgumentCompleter -Native -CommandName $availableToCompleteArray -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$fullpath = (Get-Command $wordToComplete.CommandElements[0]).Source
$arguments = $wordToComplete.Extent.ToString().Replace('"', '\"')
dotnet-suggest get -e $fullpath --position $cursorPosition -- "$arguments" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
$env:DOTNET_SUGGEST_SCRIPT_VERSION = "1.0.0"
# dotnet suggest script end
# iwr https://gist.githubusercontent.com/takekazuomi/d3e80d0be4c7fb7db77194c3a10cf87d/raw/49deeb8bf2250085472e642005d00ff3a2638026/setup.ps1 -UseBasicParsing | iex
#mkdir (Split-Path $PROFILE -Parent) -ErrorAction SilentlyContinue;Invoke-WebRequest -Uri https://gist.githubusercontent.com/takekazuomi/d3e80d0be4c7fb7db77194c3a10cf87d/raw/c4d9a54e9fbf64b7783fef1cbf0cffb235855372/Microsoft.PowerShell_profile.ps1 -OutFile $PROFILE
mkdir (Split-Path $PROFILE -Parent) -ErrorAction SilentlyContinue;curl.exe
https://gist.githubusercontent.com/takekazuomi/d3e80d0be4c7fb7db77194c3a10cf87d/raw/a5a0ef5ad6e9deea7ab8adb5a447d44664edb402/Microsoft.PowerShell_profile.ps1 -o $PROFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment