shell - MadBomber/aia GitHub Wiki
Shell Integration
The --shell
option has been discontinued. Shell integration like ERB integration is now turned on all the time.
The AIA shell integraztion is a very powerful tool in your prompt engineering. It enables the AIA program to do two things that it normally does not do:
-
Access the value of system environment variables (envars) that have the pattern of
$USER
or${USER}
- the envar must be in all uppercase. -
Execute shell commands referenced using the pattern
$(shell command)
where the shell command can be as simple or as complex as needed. Only the output to STDOUT from the shell command is inserted in the prompt text file at the point where it is executed.
The use of envars within a prompt text file is similar to the use of parameters (aka keywords) in that the prompt text is dynamically changed to include their value. The difference is and the power of using envars lies in the bypassing of asking you for a value.
When using a keyword, for example [ROLE]
, the AIA program shows you the name of the parameter in your terminal and asks for a value to use as its replacement. When you use an envar it already has a value so AIA does not have to enter an interactive mode. It just takes the value of the envar, replaces it in the prompt text and continues with its processing.
Shell Command Execution
Having access to any programming language when composing a prompt provides both flexibility and power - two things that almost always result in mistakes. So be careful when using this capability.
Why would you want to execute a shell command within a prompt? Here are some possible applications:
- Adapting a shared prompt to a specific platform
$(uname -v)
- Erasing your entire disk drive
$(rm -fr /)
That's a joke. Don't try it. - Inserting the content of another text file
$(cat other.txt)
- Inserting the headlines from today's news
$(curl https://news.google.com/news/rss | xidel -e "//item/title")
- Maybe you have some more complex workflow that you have setup tasks inside the
just
task runner$(just my_complex_task)
- What about using information from your database which you have a Rake task setup to extract
$(rake db:users:export:to_text[:late_on_payment])
To recap you can use this shell integration in your prompt text files to:
- Tailor the prompt text
- Provide additional, current information in the prompt text
- Really mess things up, so be careful!