Skip to content

Instantly share code, notes, and snippets.

@Chubek
Created September 3, 2025 03:03
Show Gist options
  • Select an option

  • Save Chubek/153beb7eabf7d3db9df063702ea93ca7 to your computer and use it in GitHub Desktop.

Select an option

Save Chubek/153beb7eabf7d3db9df063702ea93ca7 to your computer and use it in GitHub Desktop.
Fish function for getting the value of IRR against USD

Get-IRR2USD Fish Function

Below is a small, tiny Fish shell function that, when ran, notifies you of the price of IRR against USD. For example:

$ get-irr2usd
> USD <-> IRR XCHG Price: 1036862IRR

It does not have any parameters, but it takes one extra step, and saves the result of your query into a file specified by the GET_IRR2USD_LOG_FILE environment variable. You can set this variable in $XDG_CONFIG_HOME/fish/config.fish. On most distributions, this is equivalent to ‍÷/.config/fish/config.fish.

Installing the function

If you are a Fish user, you probably know that already? I don't need to tell ya. But for the sake of closure, wget(1) get-irr2usd.fish into $XDG_CONFIG_HOME/fish/functions. If you have even the least wrinkliest of brains, you might already have deduced that, on most distros, it's equivalent to ~/.config/fish/functions.

Another way to do so is, to copy and then paste the function from your browser, into your terminal, then press Enter, then type in funcsave get-irr2usd and you are golden.

Crontab

This function could be useful as a cronjob. But remmeber to replace $GET_IRR2USD_LOG_FILE with an actual, absolute path. Like ~/misery.log.

Parsing the log file

You may ask, why I am not saving the logs in a machine-friendly format, like CSV. Well, that's because I want it to be human-readable. Parsing the file is pretty simple if your brain is not full of worms.

I don't know what this is all about

Install Linux.

I can't read this, can you explain in Persian?

No.

This is a simple script. You are gloating for no reason.

Screw you. I am just sharing a function. Visit my profile for +70 projects, big and small. I am mostly active in systems programming, and PLT (Programming Language Theory).

I've fallen in love with you, and I want you to marry my sister, how can I contact you, Your Glory?

Disocrd: .chubak

Telegram: @rapturemaster

function get-irr2usd
set -l HTTPS_PROXY ""
set -l price (curl -s --location 'https://publicapi.ramzinex.com/exchange/api/v1.0/exchange/orderbooks/11/market_buy_price' | jq '.data')
if test -z "$price"
return
end
echo 'USD <-> IRR XCHG Price:' "$price"IRR
echo "At: $(date) ->" "$price"IRR\; >> $GET_IRR2USD_LOG_FILE
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment