ترفندهای برنامه‌نویسی
163 subscribers
27 photos
3 videos
22 files
615 links
Download Telegram
دوستانی که ویندوز دارین استفاده میکنید یه سری تنظمیات هستن میتونید انجام بدین و یکمی پاورشل رو بهتر کنید.
ویدئو اخر دوره‌ی وب‌سایت چند زبانه با جنگو، خودم ویندوز داشتم و ترمینالم پاورشل بود که این تنظمیات رو داشته:
اون فونت رو نصب میکنید، تا شکلک‌های powerline چه تو لینوکس چه تو ویندوز براتون درست نمایش داده بشن.
بعد هم پاورشل رو تنظیم میکنیم.

https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/

https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup


خلاصه‌ی مهم این دوتا لینک این میشه:

Set-ExecutionPolicy RemoteSigned

Register-PSRepository -Default

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

notepad $PROFILE
نت‌پد که باز شد، این متن پایین رو بریزید داخلش و سیو کنید.

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme Powerlevel10k_Classic
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineKeyHandler -Chord "End" -Function AcceptSuggestion
Set-PSReadlineKeyHandler -Key "Tab" -Function MenuComplete
Set-PSReadlineKeyHandler -Key "UpArrow" -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key "DownArrow" -Function HistorySearchForward
Set-PSReadLineOption -Colors @{ InlinePrediction = '#898c5b'}
Set-PSReadlineOption -HistorySearchCursorMovesToEnd

آی‌دی کانال👇:
programming_tricks
windows PowerShell zsh!!

install oh-my-posh

after the installation finished open a powershell and run notepad $profile then paste the following code to the file and save it.

- the code provided here will change the behavior of powershell in some order, history, code completion, up/down/left/right arrow keys functionality and so on.

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\robbyrussel.omp.json" | Invoke-Expression

Set-PSReadLineOption -PredictionSource History
Set-PSReadlineKeyHandler -Key "Tab" -Function MenuComplete
Set-PSReadlineKeyHandler -Key "UpArrow" -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key "DownArrow" -Function HistorySearchForward
Set-PSReadLineOption -Colors @{ InlinePrediction = '#898c5b'}
Set-PSReadlineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key "RightArrow" -ScriptBlock {
param($key, $arg)

$line = $null
$cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)

if ($cursor -lt $line.Length) {
[Microsoft.PowerShell.PSConsoleReadLine]::ForwardChar($key, $arg)
} else {
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptNextSuggestionWord($key, $arg)
}
}

Set-PSReadLineKeyHandler -Key End -ScriptBlock {
param($key, $arg)

$line = $null
$cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)

if ($cursor -lt $line.Length) {
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine($key, $arg)
} else {
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptSuggestion($key, $arg)
}
}