Pseudoterminal
The pseudoterminal that Fig spawns in the background when you open up
autocomplete is only initially sourced with minimal environment variables (mainly just your $PATH
).
Sometimes, scripts
that are run from a completion spec rely on these
environment variables. for example the AWS completion spec uses the AWS CLI. The
AWS CLI relies on environment variables like AWS_ACCESS_KEY_ID
etc (see
them here)
How do I set environment variables in Fig's pseudoterminal?
There are two ways:
~/.fig/user/ptyrc
This file is sourced by the pseudoterminal every time autocomplete is loaded. Add your environment variables to theptyrc
file like this:export MY_VARIABLE="hello world"
- Add items to your pty.env fig
setting:
fig settings pty.env '["LESS","OLDPWD","AWS"]'
The pty.env setting takes a JSON array of strings. Upon runningfig source
, Fig will source all environment variables in your current shell session that match the environment variables you have set in your pty.env setting. It will also match all environment variables that share a prefix with a string in your Fig settings. For example, if my pty.env setting was'["AWS"]'
, then after running Fig source, all local environment variables starting with AWS (for exampleAWS
,AWS_ACCESS_KEY_ID
,AWS_DEFAULT_REGION
etc) will be set in Fig's pseudoterminal. Note: Again, you must runfig source
manually each time you want to set environment variables using this method. Fig does not know any of your environment variables exist unless you've added it to yourptyrc
file or it's in your pty.env setting and you runfig source
. We are exploring ways of doing this is more streamlined.
Other
When your pseudoterminal spawns, Fig also sources this
file: ~/.fig/tools/ptyrc
. However, this is overridden by the Fig team on every
update. You can see this file and make changes in the withfig/config repo
here: https://github.com/withfig/config/tree/main/tools