/
profile.example.ps1
35 lines (28 loc) · 1.09 KB
/
profile.example.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Import module from current folder
Import-Module .\OpenWeatherMap
# Import weather from global module path ($env:PSModulePath)
# Import-Module OpenWeatherMap
Function Write-LocalWeatherCurrent([switch]$Inline) {
# Replace city and API key
Write-WeatherCurrent -City Minneapolis -ApiKey xxx -Units imperial -Inline:$Inline
}
Function Write-LocalWeatherForecast($Days = 1) {
# Replace city and API key
Write-WeatherForecast -City Minneapolis -ApiKey xxx -Units imperial -Days $Days
}
# EXAMPLE: Write at startup
Write-Host "Weather: " -NoNewline -ForegroundColor Yellow
Write-LocalWeatherCurrent
# Type `weather` in the prompt to see current weather
Set-Alias weather Write-LocalWeatherCurrent
# Type `forecast` or `forecast -d 2` to get the current forecast
Set-Alias forecast Write-LocalWeatherForecast
# EXAMPLE: Override prompt and include inline weather
Function Prompt() {
# Write current dir
Write-Host ($PWD) -NoNewline -ForegroundColor Red
# Write inline weather
Write-LocalWeatherCurrent -Inline
Write-Host "›" -NoNewline -ForegroundColor Gray
return ' '
}