mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
28 lines
No EOL
888 B
PowerShell
28 lines
No EOL
888 B
PowerShell
$_userForexToday = (Get-Content ~/.forex | ConvertFrom-Json).conversion_rates
|
|
|
|
function Update-ForexData {
|
|
((Invoke-WebRequest "$_userForexUrl").Content | ConvertFrom-Json).conversion_rates > ~/.forex
|
|
}
|
|
function Get-ExchangeRate {
|
|
param (
|
|
[string] $From,
|
|
[string] $To = "CNY",
|
|
[double] $Value = 1
|
|
)
|
|
if (-not $from) {
|
|
Get-ForexOverview
|
|
return
|
|
}
|
|
Write-Host $From : $To " " -NoNewline -ForegroundColor DarkGreen
|
|
($Value * ($_userForexToday.$To / $_userForexToday.$From)) | Write-Host -ForegroundColor DarkBlue
|
|
}
|
|
|
|
function Get-ForexOverview {
|
|
Get-ExchangeRate -From GBP -To CNY -Value 1
|
|
Get-ExchangeRate -From USD -To CNY -Value 1
|
|
Get-ExchangeRate -From HKD -To CNY -Value 1
|
|
Get-ExchangeRate -From EUR -To CNY -Value 1
|
|
Get-ExchangeRate -From CNY -To JPY -Value 1
|
|
}
|
|
|
|
Set-Alias "forex" "Get-ExchangeRate" |