Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature (OWM) - Add ability to set the location parameter by an Environmental Variable #5478

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JamesAndrewJackson13
Copy link

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Within the OWM segment, add the ability to set the location property via an environmental variable (just like how the API key can be set that way).

This allows for the location to be dynamically set, which allows for the location to be updated depending on where the user is. Useful for anyone running oh-my-posh on a laptop and changes location often. Without this change, if you want to do something like this you have to manually insert the location into the config file right before passing it to oh-my-posh (at least that's how I'm doing it; may not be the best method).

Note

For anyone curious about how you can get your location within PowerShell (on Windows), this stackoverflow post shows how to use the location-api. That gets your lat-long position. You'll then need to send that to a reverseGeocode api of some kind to get the city name, state code and country code (I was using Bing Maps API to do it, since it was free, but since that is getting shut down next year I've moved to Azure Maps).


location = url.QueryEscape(location)
location := d.props.GetString(Location, "De Bilt,NL")
if len(location) == 0 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never be true, right? We default to a value when fetching the location from the properties which implies location will always have a value.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JamesAndrewJackson13 any update on this remark?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants