about summary refs log tree commit diff
path: root/configs
diff options
context:
space:
mode:
Diffstat (limited to 'configs')
-rw-r--r--configs/shared/zsh/functions.zsh20
1 files changed, 20 insertions, 0 deletions
diff --git a/configs/shared/zsh/functions.zsh b/configs/shared/zsh/functions.zsh
index 60e512e8fb79..ae259853978b 100644
--- a/configs/shared/zsh/functions.zsh
+++ b/configs/shared/zsh/functions.zsh
@@ -172,6 +172,26 @@ kush() {
 }
 
 # Misc
+monzo_balance() {
+  # Return the balance of my Monzo bank account. Intended to be used in my i3
+  # status bar.
+  # Usage: monzo_balance
+  # Depends:
+  #   - ~/Dropbox/monzo_creds.json.gpg (encrypted asymmetrically for yourself)
+  #   - httpie
+  #   - jq
+  #   - gpg
+  local creds=$(gpg --decrypt ~/Dropbox/monzo_creds.json.gpg 2>/dev/null)
+  local access_token=$(echo $creds | jq --raw-output .access_token)
+  local account_id=$(echo $creds | jq --raw-output .account_id)
+  local balance=$(http --body https://api.monzo.com/balance \
+                       "Authorization: Bearer ${access_token}" \
+                       "account_id==${account_id}" | \
+                    jq .balance)
+
+  echo "£$balance"
+}
+
 tldr_docs() {
   # Helper function for submitting a new page to `tldr`.
   # Usage: tldr_docs <cmd-name>