From 0b0311bb5f2ea2b5b564fe35f17cd92bd51b05dc Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Wed, 1 Sep 2021 21:19:46 +0400 Subject: [PATCH] setup powershell / ohmyposh --- init.sh | 19 ++++++ posh_config.json | 149 +++++++++++++++++++++++++++++++++++++++++ powershell_profile.ps1 | 16 +++++ 3 files changed, 184 insertions(+) create mode 100644 init.sh create mode 100644 posh_config.json create mode 100644 powershell_profile.ps1 diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..895fa25 --- /dev/null +++ b/init.sh @@ -0,0 +1,19 @@ +#!/bin/sh + + +sudo apt-get update +sudo apt-get install -y wget apt-transport-https software-properties-common +wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb +sudo dpkg -i packages-microsoft-prod.deb +rm packages-microsoft-prod.deb +sudo apt-get update +sudo add-apt-repository universe +sudo apt-get install -y powershell +chsh -s /usr/bin/pwsh + +sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh +sudo chmod +x /usr/local/bin/oh-my-posh + +cp powershell_profile.ps1 $PROFILE +mkdir -p ~/.config/ohmyposh +cp posh_config.json -p ~/.config/ohmyposh/config.json \ No newline at end of file diff --git a/posh_config.json b/posh_config.json new file mode 100644 index 0000000..7fc0d83 --- /dev/null +++ b/posh_config.json @@ -0,0 +1,149 @@ +{ + "blocks": [ + { + "type": "prompt", + "alignment": "left", + "segments": [ + { + "type": "path", + "style": "diamond", + "powerline_symbol": "", + "foreground": "#ffffff", + "background": "#ff479c", + "properties": { + "prefix": "  ", + "home_icon": "~", + "folder_separator_icon": " \uE0b1 ", + "style": "folder" + } + }, + { + "type": "session", + "style": "powerline", + "foreground": "#ffffff", + "background": "#c386f1", + "leading_diamond": "", + "trailing_diamond": "", + "properties": { + "postfix": " ", + "display_host": true, + "display_user": false + } + }, + { + "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": "node", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#111111", + "background": "#8ED1F7", + "properties": { + "prefix": " \uE626 ", + "display_version": true + } + }, + { + "type": "go", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#111111", + "background": "#8ED1F7", + "properties": { + "prefix": " \uE626 ", + "display_version": true + } + }, + { + "type": "rust", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#111111", + "background": "#8ED1F7", + "properties": { + "prefix": " \uE626 " + } + }, + { + "type": "dotnet", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#111111", + "background": "#8ED1F7", + "properties": { + "display_version": true, + "prefix": " \uE626 " + } + }, + { + "type": "azfunc", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#ffffff", + "background": "#FEAC19", + "properties": { + "prefix": " \uf0e7", + "display_version": false, + "display_mode": "files" + } + }, + { + "type": "root", + "style": "powerline", + "powerline_symbol": "", + "foreground": "#111111", + "background": "#ffff66", + "properties": { + "root_icon": "" + } + }, + { + "type": "exit", + "style": "diamond", + "foreground": "#ffffff", + "background": "#2e9599", + "leading_diamond": "", + "trailing_diamond": "", + "properties": { + "display_exit_code": false, + "always_enabled": true, + "error_color": "#f1184c", + "color_background": true, + "prefix": "<#83769c> " + } + } + ] + }, + { + "type": "rprompt", + "segments": [ + { + "type": "time", + "style": "diamond", + "invert_powerline": true, + "leading_diamond": "\uE0B2", + "trailing_diamond": "\uE0B4", + "background": "#2e9599", + "foreground": "#111111" + } + ] + } + ], + "final_space": true, + "console_title": true, + "console_title_style": "template", + "console_title_template": "{{.Folder}} @ {{.Host}}" + } \ No newline at end of file diff --git a/powershell_profile.ps1 b/powershell_profile.ps1 new file mode 100644 index 0000000..491a398 --- /dev/null +++ b/powershell_profile.ps1 @@ -0,0 +1,16 @@ +oh-my-posh --init --shell pwsh --config ~/.config/ohmyposh/config.json | Invoke-Expression +Import-Module Terminal-Icons +Import-Module PSReadLine +Set-PSReadLineOption -PredictionSource History +Set-PSReadLineOption -PredictionViewStyle ListView +Set-PSReadLineOption -EditMode Windows +Function fndclogs([string]$container) {docker logs -f --tail 100 $container} +Set-Alias -Name dclogs -Value fndclogs +Function fndcupd {docker-compose up -d --remove-orphans} +Set-Alias -Name dcupd -Value fndcupd +Function fndcdown {docker-compose down} +Set-Alias -Name dcdown -Value fndcdown +Function fnfullupdate {sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get autoclean -y} +Set-Alias -Name fullupdate -Value fnfullupdate +Function fnll {ls -la} +Set-Alias -Name ll -Value fnll