From 861df3678fadd08ed47518ad5cc2f1cccc72f8ca Mon Sep 17 00:00:00 2001 From: "Florian RICHER (MrDev023)" Date: Wed, 27 Oct 2021 20:35:40 +0200 Subject: [PATCH] [WINDOWS] Add configuration for powershell --- configs/powershell/ohmyposh.json | 72 +++++++++++++++++++ install.ps1 | 38 ++++++++++ install.sh | 0 .../install_scripts}/ubuntu.sh | 0 .../useful_scripts}/cleanup_wsl_mem.sh | 0 5 files changed, 110 insertions(+) create mode 100644 configs/powershell/ohmyposh.json create mode 100644 install.ps1 mode change 100755 => 100644 install.sh rename {install_scripts => linux/install_scripts}/ubuntu.sh (100%) mode change 100755 => 100644 rename {useful_scripts => linux/useful_scripts}/cleanup_wsl_mem.sh (100%) diff --git a/configs/powershell/ohmyposh.json b/configs/powershell/ohmyposh.json new file mode 100644 index 0000000..3818fe6 --- /dev/null +++ b/configs/powershell/ohmyposh.json @@ -0,0 +1,72 @@ +{ + "final_space": true, + "console_title": true, + "console_title_style": "folder", + "blocks": [ + { + "type": "prompt", + "alignment": "left", + "horizontal_offset": 0, + "vertical_offset": 0, + "segments": [ + { + "type": "path", + "style": "diamond", + "powerline_symbol": "", + "invert_powerline": false, + "foreground": "#ffffff", + "background": "#ff479c", + "leading_diamond": "", + "trailing_diamond": "", + "properties": { + "prefix": "  ", + "style": "folder" + } + }, + { + "type": "git", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": false, + "foreground": "#193549", + "background": "#fffb38", + "leading_diamond": "", + "trailing_diamond": "", + "properties": { + "display_status": true, + "display_stash_count": true, + "display_upstream_icon": true + } + }, + { + "type": "root", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": false, + "foreground": "#ffffff", + "background": "#ffff66", + "leading_diamond": "", + "trailing_diamond": "", + "properties": null + }, + { + "type": "exit", + "style": "powerline", + "powerline_symbol": "", + "invert_powerline": false, + "foreground": "#ffffff", + "background": "#2e9599", + "leading_diamond": "", + "trailing_diamond": "", + "properties": { + "always_enabled": true, + "color_background": true, + "display_exit_code": false, + "error_color": "#f1184c", + "prefix": " " + } + } + ] + } + ] +} \ No newline at end of file diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..a1ba863 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,38 @@ +# Install OhMyPosh +winget install JanDeDobbeleer.OhMyPosh + +# Reload path +$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + +# Install modules +Install-Module -Name Terminal-Icons -Repository PSGallery -Force +Install-Module -Name PSReadLine -AllowPrerelease -Force + +# Update profile configuration + +# 1. Import all required params +$powershellConfig = (Get-Location).Path + "\configs\powershell\phmyposh.json" +Write-Output @' +function Reload-Path { + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +} + +Reload-Path +'@ | Out-File -FilePath $PROFILE +Write-Output 'Import-Module -Name Terminal-Icons' | Out-File -FilePath $PROFILE -Append +Write-Output @' +if ($host.Name -eq 'ConsoleHost') +{ + Import-Module -Name PSReadLine +} +'@ | Out-File -FilePath $PROFILE -Append +Write-Output "oh-my-posh --init --shell pwsh --config '$powershellConfig' | Invoke-Expression" | Out-File -FilePath $PROFILE -Append + +# 2. Configure PSReadLine | Predictive Intellisense +Write-Output 'Set-PSReadLineOption -PredictionSource History' | Out-File -FilePath $PROFILE -Append +Write-Output 'Set-PSReadLineOption -HistoryNoDuplicates:$True' | Out-File -FilePath $PROFILE -Append +Write-Output 'Set-PSReadLineOption -ShowToolTips:$True' | Out-File -FilePath $PROFILE -Append +Write-Output 'Set-PSReadLineOption -EditMode Windows' | Out-File -FilePath $PROFILE -Append + +# Reload profile +. $PROFILE \ No newline at end of file diff --git a/install.sh b/install.sh old mode 100755 new mode 100644 diff --git a/install_scripts/ubuntu.sh b/linux/install_scripts/ubuntu.sh old mode 100755 new mode 100644 similarity index 100% rename from install_scripts/ubuntu.sh rename to linux/install_scripts/ubuntu.sh diff --git a/useful_scripts/cleanup_wsl_mem.sh b/linux/useful_scripts/cleanup_wsl_mem.sh similarity index 100% rename from useful_scripts/cleanup_wsl_mem.sh rename to linux/useful_scripts/cleanup_wsl_mem.sh