Last active
July 31, 2024 13:44
-
-
Save rkttu/3d286f711ebd7de239489fc3310a80cd to your computer and use it in GitHub Desktop.
How to initialize oh-my-posh with bash (macOS), bash (WSL, Ubuntu), cmd, zsh and pwsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for bash (macOS) | |
POSH_THEMES_PATH=$(brew --prefix oh-my-posh)/themes | |
eval "$(oh-my-posh completion bash)" | |
eval "$(oh-my-posh init bash --config "$POSH_THEMES_PATH"/clean-detailed.omp.json | sed 's|\[\[ -v MC_SID \]\]|[[ -n "$MC_SID" ]]|')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for bash (Ubuntu, WSL) | |
# # Download the themes before getting started. | |
# sudo apt install curl unzip | |
# mkdir ~/.poshthemes | |
# curl -L https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -o ~/.poshthemes/themes.zip | |
# unzip ~/.poshthemes/themes.zip -d ~/.poshthemes | |
# chmod u+rw ~/.poshthemes/*.json | |
# rm ~/.poshthemes/themes.zip | |
eval "$(oh-my-posh completion bash)" | |
eval "$(oh-my-posh init bash --config ~/.poshthemes/clean-detailed.omp.json)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for zsh | |
autoload -Uz compinit | |
compinit | |
POSH_THEMES_PATH=$(brew --prefix oh-my-posh)/themes | |
eval "$(oh-my-posh completion zsh)" | |
eval "$(oh-my-posh init zsh --config "$POSH_THEMES_PATH"/clean-detailed.omp.json)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before editing PROFILE script, make sure the PROFILE directory exists. | |
# mkdir -Path (Get-Item -Path $PROFILE).Directory.FullName -ErrorAction SilentlyContinue | |
# for PowerShell (macOS) | |
if ([Environment]::OSVersion.Platform -eq [PlatformID]::MacOSX) { | |
$env:POSH_THEMES_PATH = Join-Path -Path "$(brew --prefix oh-my-posh)" -ChildPath themes | |
[scriptblock]::Create($(oh-my-posh completion powershell)).Invoke() | |
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/clean-detailed.omp.json" | iex | |
} | |
# for PowerShell (Windows) | |
if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { | |
$env:POSH_THEMES_PATH = Join-Path -Path (Get-Item -Path (Get-Command -Name 'oh-my-posh').Source).Directory.Parent.FullName -ChildPath 'themes' | |
[scriptblock]::Create($(oh-my-posh completion powershell)).Invoke() | |
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/clean-detailed.omp.json" | iex | |
} | |
# for PowerShell (Linux, Ubuntu) | |
# # Download the themes before getting started. | |
# sudo apt install curl unzip | |
# mkdir ~/.poshthemes | |
# curl -L https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -o ~/.poshthemes/themes.zip | |
# unzip ~/.poshthemes/themes.zip -d ~/.poshthemes | |
# chmod u+rw ~/.poshthemes/*.json | |
# rm ~/.poshthemes/themes.zip | |
if ([Environment]::OSVersion.Platform -eq [PlatformID]::Unix) { | |
$env:POSH_THEMES_PATH = Join-Path -Path $Home -ChildPath '.poshthemes' | |
[scriptblock]::Create($(oh-my-posh completion powershell)).Invoke() | |
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/clean-detailed.omp.json" | iex | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Install clink via "winget install Clink". | |
-- Then, create oh-my-posh.lua file in the "%localappdata%\clink\oh-my-posh.lua". | |
-- Note: Clink version does not support auto-completion feature. | |
load(io.popen('oh-my-posh init cmd --config ' | |
.. os.getenv("localappdata") | |
.. '\\Programs\\oh-my-posh\\themes\\clean-detailed.omp.json'):read("*a"))() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment