CodeFaster

CodeFaster

Share this post

CodeFaster
CodeFaster
Unix 1 liner for getting an API key into google sheets

Unix 1 liner for getting an API key into google sheets

Tyler Adams's avatar
Tyler Adams
Jul 12, 2023
∙ Paid
2

Share this post

CodeFaster
CodeFaster
Unix 1 liner for getting an API key into google sheets
3
Share

I needed to get my OPENAPI key for use in gsheets, it’s in my env, here’s how to do it in a 1 liner

env | grep OPENAI_API | cut -d '=' -f 2 | pbcopy

# EDIT, this is a great pipeline for teaching, but my reader George points out env variables are variables, so we can simplify this to:
echo $OPEN_API_KEY | pbcopy

Thanks for reading CodeFaster! Subscribe for free to receive new posts and support my work.

env gets all environment variables

LANGUAGE=en_US
I3SOCK=/run/user/1000/i3/ipc-socket.3145
MANDATORY_PATH=/usr/share/gconf/i3.mandatory.path
OPENAI_API_KEY=MY_KEY
DESKTOP_SESSION=i3
XTERM_SHELL=/bin/bash
EDITOR=vim
GTK_MODULES=gail:atk-bridge
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=i3

grep selects OPEN_API

OPENAI_API_KEY=MY_KEY

Cut splits by = and selects the 2nd (1 index)

MY_KEY

and pbcopy puts it into my clipboard where I paste it from in chrome.

Happy hacking

Thanks for reading CodeFaster! Subscribe for free to receive new posts and support my work.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Tyler Adams
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share