====== o-my-posh ====== [[:start#computer|Home]] / [[windows:install|Back]] ---- Um o-my-posh zu installieren ist das herunterladen erforderlich. Dies kann mithilfe der PowerShell und des nachfolgenden Kommandos durchgeführt werden. {{:windows:win_powershell_search.png?500|}} Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1')) {{:windows:install:omp_01_ps_download.png?500|}} {{:windows:install:omp_02_ps_install_complete.png?500|}} Nach dem herunterladen ist ein Neustart der PowerShell erforderlich (schließen und wieder öffnen) und mit nachfolgendem Kommando zu überprüfen ob die Installation von o-my-posh erfolgreich war. o-my-posh --version {{:windows:install:omp_03_check_version.png?400|}} Um o-my-posh verwenden zu können ist die Installation benötigter Fonts erforderlich. Dies kann mit nachfolgendem Kommando durchgeführt werden. oh-my-posh font install meslo {{:windows:install:omp_04_install_font.png?400|}} Nach dem Abschluss der Installation kann mit der Einbindung in die [[#PowerShell_Integration|Powershell]] bzw. die [[#git_Bash_Integration|git Bash]] fortgesetzt werden. ====== PowerShell Integration ====== Um o-my-posh in der PowerShell zu aktivieren ist es erforderlich die heruntergeladene Font zu aktivieren. Diese Einstellung kann durch die Tastenkombination STRG + SHIFT + , aufgerufen werden. {{:windows:win_powershell.png?500|}} In den profiles sind folgende Einstellungen zu ergänzen. Alle anderen Einstellungen sind unverändert zu lasssen. { "profiles": { "defaults": { "font": { "face": "MesloLGM Nerd Font" } } } } Zuletzt ist noch über das nachfolgende Kommando o-my-posh in das Profil der Power-Shell einzutragen. notepad $PROFILE {{:windows:install:omp_05_edit_powershell.png?500|}} oh-my-posh init pwsh --config %USERPROFILE%\o-my-posh.json | Invoke-Expression Sollte es zu einem Fehler beim Öffnen der Datei kommen ist folgendes Kommando auszuführen: New-Item -Path $PROFILE -Type File -Force Nach dem hinzufügen der o-my-posh initialisierung ist noch ein [[#Theme|Theme]] zu wählen und im ''%USERPROFILE%'' Ordner unter ''o-my-posh.json'' zu speichern. Anschließend ist die PowerShell neu starten (schließen und wieder öffnen). {{:windows:install:omp_06_powershell.png?600|}} Wird ''o-my-posh'' nicht gestartet und eine Fehlermeldung angezeigt (siehe Bild), kann das Ausführen von Skripten in der PowerShell durch Windows blockiert sein. {{:windows:install:omp_06_powershell_error.png?600|}} Um dies zu aktivieren ist folgender Befehl (in der [[windows:system-programs:ps|Powershell]] als Administrator) auszuführen: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine ====== git Bash Integration ====== Um o-my-posh in der git Bash zu aktivieren ist es erforderlich die heruntergeladene Font zu aktivieren. Diese Einstellung kann in den Optionen der Konsole aktiviert werden. {{:windows:install:git_15_start_application.png?500|}} {{:windows:install:omp_06_bash_options.png?500|}} Im linken Menü auf Text wechseln. {{:windows:install:omp_07_bash_font_select.png?400|}} Und nachfolgende Font einstellen. {{:windows:install:omp_08_bash_font.png?400|}} Zuletzt ist noch über das nachfolgende Kommando o-my-posh in die .bashrc der git Bash einzutragen. notepad .bashrc {{:windows:install:omp_05_edit_bashrc.png?500|}} eval "$(oh-my-posh --init --shell bash --config ~/o-my-posh.json)" Nach dem hinzufügen der o-my-posh initialisierung ist noch ein [[#Theme|Theme]] zu wählen und im %USERPROFILE% Ordner unter o-my-posh.json zu speichern. Anschließend die git Bash neu starten (schließen und wieder öffnen). {{:windows:install:omp_06_bash.png?500|}} ---- ====== Theme ====== Unter folgendem [[https://ohmyposh.dev/docs/themes|Link]] kann ein entsprechendes Theme gewählt oder auf das hier zur Verfügung gestellte Theme zurückgegriffen werden. { "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "version": 2, "final_space": true, "console_title_template": "{{ .Shell }} in {{ .Folder }}", "blocks": [ { "type": "prompt", "alignment": "left", "segments": [ { "type": "session", "style": "diamond", "foreground": "p:black", "background": "p:yellow", "leading_diamond": "\ue0b6", "trailing_diamond": "\ue0b0", "template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} " }, { "type": "path", "style": "powerline", "powerline_symbol": "\ue0b0", "foreground": "p:white", "background": "p:orange", "template": " \uf74a {{ path .Path .Location }} ", "properties": { "style": "folder" } }, { "type": "git", "style": "powerline", "powerline_symbol": "\ue0b0", "foreground": "p:black", "foreground_templates": [ "{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}", "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}", "{{ if gt .Ahead 0 }}p:white{{ end }}" ], "background": "p:green", "background_templates": [ "{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}", "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}", "{{ if gt .Ahead 0 }}#49416D{{ end }}", "{{ if gt .Behind 0 }}#7A306C{{ end }}" ], "template": " {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }} ", "properties": { "branch_max_length": 25, "fetch_status": true, "fetch_upstream_icon": true, "github_icon": "\uf7a3" } }, { "type": "root", "style": "powerline", "powerline_symbol": "\ue0b0", "foreground": "p:white", "background": "p:yellow", "template": " \uf0e7 " }, { "type": "exit", "style": "diamond", "foreground": "p:white", "background": "p:blue", "background_templates": [ "{{ if gt .Code 0 }}p:red{{ end }}" ], "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b4", "template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ", "properties": { "always_enabled": true } } ] }, { "type": "rprompt", "segments": [ { "type": "node", "style": "plain", "foreground": "p:green", "background": "transparent", "template": "\uf898 ", "properties": { "display_mode": "files", "fetch_package_manager": false, "home_enabled": false } }, { "type": "go", "style": "plain", "foreground": "p:blue", "background": "transparent", "template": "\ufcd1 ", "properties": { "fetch_version": false } }, { "type": "python", "style": "plain", "foreground": "p:yellow", "background": "transparent", "template": "\ue235 ", "properties": { "display_mode": "files", "fetch_version": false, "fetch_virtual_env": false } }, { "type": "shell", "style": "plain", "foreground": "p:white", "background": "transparent", "template": "in {{ .Name }} " }, { "type": "time", "style": "plain", "foreground": "p:white", "background": "transparent", "template": "at {{ .CurrentDate | date \"15:04:05\" }}" } ] } ], "tooltips": [ { "type": "aws", "tips": [ "aws" ], "style": "diamond", "foreground": "p:white", "background": "p:orange", "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b4", "template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ", "properties": { "display_default": true } }, { "type": "az", "tips": [ "az" ], "style": "diamond", "foreground": "p:white", "background": "p:blue", "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b4", "template": " \ufd03 {{ .Name }} ", "properties": { "display_default": true } } ], "transient_prompt": { "foreground": "p:black", "background": "transparent", "template": "\ue0b6<,p:yellow> {{ .Folder }} \ue0b0 " }, "secondary_prompt": { "foreground": "p:black", "background": "transparent", "template": "\ue0b6<,p:yellow> > \ue0b0 " }, "palette": { "black": "#262B44", "blue": "#4B95E9", "green": "#59C9A5", "orange": "#F07623", "red": "#D81E5B", "white": "#E0DEF4", "yellow": "#F3AE35" } } ---- [[:start#computer|Home]] / [[windows:install|Back]]