refactor: hello world oh-my-posh3

This commit is contained in:
Jan De Dobbeleer 2020-10-03 20:36:49 +02:00 committed by Jan De Dobbeleer
parent 1a52aa9b04
commit d3207328e5
7 changed files with 34 additions and 65 deletions

View file

@ -92,7 +92,7 @@ jobs:
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}/packages/powershell/go-my-posh
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}/packages/powershell/oh-my-posh
env:
PSGALLERY_KEY: ${{ secrets.PSGALLERY_KEY }}
steps:

View file

@ -1,7 +1,8 @@
# A prompt theme engine for any shell
![example workflow name](https://github.com/jandedobbeleer/go-my-posh/workflows/Release/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/jandedobbeleer/go-my-posh)](https://goreportcard.com/report/github.com/jandedobbeleer/go-my-posh)
![Release Status](https://github.com/jandedobbeleer/oh-my-posh3/workflows/Release/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/jandedobbeleer/oh-my-posh)](https://goreportcard.com/report/github.com/jandedobbeleer/oh-my-posh)
[![PS Gallery][psgallery-badge]][powershell-gallery]
What started as the offspring of [oh-my-posh][oh-my-posh] for PowerShell resulted in a cross platform, highly customizable and extensible prompt theme engine. After 4 years of working on oh-my-posh, a modern and more efficient tool was needed to suit my personal needs.
@ -34,7 +35,7 @@ What started as the offspring of [oh-my-posh][oh-my-posh] for PowerShell resulte
## Installation
`go-my-posh` uses ANSI color codes under the hood, these should work everywhere,
`oh-my-posh` uses ANSI color codes under the hood, these should work everywhere,
but you may have to set your $TERM to `xterm-256color` for it to work.
For maximum enjoyment, make sure to install a powerline enabled font. The fonts I use are patched by [Nerd Fonts][nerdfonts], which offers a maximum of icons you can use to configure your prompt.
@ -44,8 +45,8 @@ For maximum enjoyment, make sure to install a powerline enabled font. The fonts
A PowerShell module is available for your enjoyment. Install and use it with the following commands.
```powershell
Install-Module -Name go-my-posh -Repository PSGallery
Import-Module go-my-posh
Install-Module -Name oh-my-posh3 -Repository PSGallery
Import-Module oh-my-posh3
Set-PoshPrompt paradox
```
@ -56,7 +57,7 @@ To see available themes, make use of the `Get-PoshThemes` function. This prints
### Precompiled Binaries
You can find precompiled binaries for all major OS's underneath the
[releases tab][releases]. Installation instruction for the different shells below assumes `<go-my-posh>` points to the go-my-posh binary and you've downloaded the [`jandedobbeleer` theme][jandedobbeleer] to your `$HOME` directory.
[releases tab][releases]. Installation instruction for the different shells below assumes `<oh-my-posh>` points to the oh-my-posh binary and you've downloaded the [`jandedobbeleer` theme][jandedobbeleer] to your `$HOME` directory.
On UNIX systems, make sure the binary is executable before using it.
@ -70,10 +71,10 @@ Add the following to your `.bashrc` (or `.profile` on Mac):
```bash
function _update_ps1() {
PS1="$(<go-my-posh> -config ~/jandedobbeleer.json -error $?)"
PS1="$(<oh-my-posh> -config ~/jandedobbeleer.json -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f <go-my-posh> ]; then
if [ "$TERM" != "linux" ] && [ -f <oh-my-posh> ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
```
@ -84,7 +85,7 @@ Add the following to your `.zshrc`:
```bash
function powerline_precmd() {
PS1="$(<go-my-posh> -config ~/jandedobbeleer.json --error $?)"
PS1="$(<oh-my-posh> -config ~/jandedobbeleer.json --error $?)"
}
function install_powerline_precmd() {
@ -107,13 +108,13 @@ Redefine `fish_prompt` in `~/.config/fish/config.fish`:
```bash
function fish_prompt
eval <go-my-posh> -config ~/jandedobbeleer.json -error $status
eval <oh-my-posh> -config ~/jandedobbeleer.json -error $status
end
```
#### Nix
When using `nix-shell --pure`, `go-my-posh` will not be accessible, and
When using `nix-shell --pure`, `oh-my-posh` will not be accessible, and
your prompt will not appear.
As a workaround you can add this snippet to your `.bashrc`,
@ -122,8 +123,8 @@ which should re-enable the prompt in most cases:
```bash
# Workaround for nix-shell --pure
if [ "$IN_NIX_SHELL" == "pure" ]; then
if [ -x <go-my-posh> ]; then
alias powerline-go="<go-my-posh> -config ~/jandedobbeleer.json"
if [ -x <oh-my-posh> ]; then
alias powerline-go="<oh-my-posh> -config ~/jandedobbeleer.json"
fi
fi
```
@ -154,6 +155,8 @@ a few general properties are available cross segments which can be found in `pro
* [Robby Russel][oh-my-zsh] for creating oh-my-zsh, without him this would probably not be here
* [Janne Mareike Koschinski][justjanne] for providing information on how to get certain information using Go (and the amazing [README][powerline-go])
[psgallery-badge]: https://img.shields.io/powershellgallery/dt/oh-my-posh.svg
[powershell-gallery]: https://www.powershellgallery.com/packages/oh-my-posh/
[oh-my-posh]: https://github.com/JanDeDobbeleer/oh-my-posh
[patreon-badge]: https://img.shields.io/badge/Support-Become%20a%20Patreon!-red.svg
[patreon]: https://www.patreon.com/jandedobbeleer
@ -161,9 +164,9 @@ a few general properties are available cross segments which can be found in `pro
[liberapay]: https://liberapay.com/jandedobbeleer
[kofi-badge]: https://img.shields.io/badge/Ko--fi-Buy%20me%20a%20coffee!-%2346b798.svg
[kofi]: https://ko-fi.com/jandedobbeleer
[releases]: https://github.com/JanDeDobbeleer/go-my-posh/releases
[jandedobbeleer]: https://github.com/JanDeDobbeleer/go-my-posh/blob/master/themes/jandedobbeleer.json
[themes]: https://github.com/JanDeDobbeleer/go-my-posh/tree/master/themes
[releases]: https://github.com/JanDeDobbeleer/oh-my-posh3/releases
[jandedobbeleer]: https://github.com/JanDeDobbeleer/oh-my-posh3/blob/master/themes/jandedobbeleer.json
[themes]: https://github.com/JanDeDobbeleer/oh-my-posh3/tree/master/themes
[chrisbenti-psconfig]: https://github.com/chrisbenti/PS-Config
[keithdahlby-poshgit]: https://github.com/dahlbyk/posh-git
[oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh

View file

@ -1,35 +0,0 @@
skip_tags: true
skip_commits:
files:
- .github/*
- README.md
- CHANGELOG.md
environment:
GH_KEY:
secure: Vd8UVmtAfMZGW0OzImzMpG3ZfBoK6xOhduxnTJwyi5DmgbMuUz84SZ7AKke8xHsJ
image:
- Visual Studio 2019
- Ubuntu
build_script:
- pwsh: (Get-Content '.\oh-my-posh.psd1' -Raw).Replace('1.0.0.0', $ENV:APPVEYOR_BUILD_VERSION) | Out-File -Encoding 'UTF8' '.\oh-my-posh.psd1'
before_test:
- pwsh: .\Build\setup_test_env.ps1
test_script:
- pwsh: >-
if ($isWindows) {
.\Build\test_windows.ps1
}
else {
Invoke-Pester
}
deploy_script:
- pwsh: >-
if ($isWindows) {
.\Build\release.ps1
}
on_success:
- git config --global credential.helper store
- ps: Add-Content -Path "$HOME\.git-credentials" -Value "https://$($env:GH_KEY):x-oauth-basic@github.com`n" -NoNewline
- git config --global user.email "Your email"
- git config --global user.name "Your Name"
- git push

View file

@ -1,6 +1,6 @@
# PowerShell package
The goal of this module is to wrap the `go-my-posh` binaries into a PowerShell module and allow easy installation
The goal of this module is to wrap the `oh-my-posh` binaries into a PowerShell module and allow easy installation
and ease of use when setting the prompt.
## Testing
@ -26,5 +26,5 @@ deploy.ps1 -BinVersion 0.1.0 -ModuleVersion 0.0.2 -Repository LocalRepo
Install/Update the module from your local repository and validate the changes.
```powershell
Install-Module go-my-posh -Repository LocalRepo -Force
Install-Module oh-my-posh -Repository LocalRepo -Force
```

View file

@ -15,13 +15,13 @@ Param
)
# set the actual version number
(Get-Content '.\go-my-posh.psd1' -Raw).Replace('0.0.0.1', $ModuleVersion) | Out-File -Encoding 'UTF8' '.\go-my-posh.psd1'
(Get-Content '.\oh-my-posh.psd1' -Raw).Replace('0.0.0.1', $ModuleVersion) | Out-File -Encoding 'UTF8' '.\oh-my-posh.psd1'
# copy all themes into the module folder
Copy-Item -Path "../../../themes" -Destination "./themes" -Recurse
# fetch all the binaries from the version's GitHub release
New-Item -Path "./" -Name "bin" -ItemType "directory"
"posh-windows-amd64.exe", "posh-darwin-amd64", "posh-linux-amd64" | ForEach-Object -Process {
$download = "https://github.com/jandedobbeleer/go-my-posh/releases/download/v$BinVersion/$_"
$download = "https://github.com/jandedobbeleer/oh-my-posh3/releases/download/v$BinVersion/$_"
Invoke-WebRequest $download -Out "./bin/$_"
}
# publish the module
@ -31,7 +31,7 @@ if ($RepositoryAPIKey) {
Publish-Module -Path . -Repository $Repository -Verbose
}
# reset module version (for local testing only as we don't want PR's with changed version numbers all the time)
(Get-Content '.\go-my-posh.psd1' -Raw).Replace($ModuleVersion, '0.0.0.1') | Out-File -Encoding 'UTF8' '.\go-my-posh.psd1'
(Get-Content '.\oh-my-posh.psd1' -Raw).Replace($ModuleVersion, '0.0.0.1') | Out-File -Encoding 'UTF8' '.\oh-my-posh.psd1'
Remove-Item "./bin" -Recurse -Force
Remove-Item "./themes" -Recurse -Force

View file

@ -1,5 +1,5 @@
#
# Module manifest for module 'go-my-posh'
# Module manifest for module 'oh-my-posh3'
#
# Generated by: Jan De Dobbeleer
#
@ -9,11 +9,11 @@
# Version number of this module.
ModuleVersion = '0.0.0.1'
# Script module or binary module file associated with this manifest.
RootModule = 'go-my-posh.psm1'
RootModule = 'oh-my-posh.psm1'
# ID used to uniquely identify this module
GUID = '60288db4-a58e-4c79-b50d-dba631950ecc'
GUID = '7d7c4a78-e2fe-4e5f-9510-34ac893e4562'
# Company or vendor of this module
CompanyName = 'IT Depends'
CompanyName = 'Unknown'
# Author of this module
Author = 'Jan De Dobbeleer'
# Copyright statement for this module
@ -35,12 +35,13 @@
# Private data to pass to the module specified in RootModule. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
Prerelease = 'beta'
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('git', 'agnoster', 'theme', 'zsh', 'posh-git', 'prompt', 'paradox', 'robbyrussel', 'oh-my-posh')
# A URL to the license for this module.
LicenseUri = 'https://github.com/JanDeDobbeleer/go-my-posh/blob/master/COPYING'
LicenseUri = 'https://github.com/JanDeDobbeleer/oh-my-posh3/blob/master/COPYING'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/JanDeDobbeleer/go-my-posh'
ProjectUri = 'https://github.com/JanDeDobbeleer/oh-my-posh3'
} # End of PSData hashtable
} # End of PrivateData hashtable
}
@ -105,5 +106,5 @@