Skip to content
Dewayne VanHoozer edited this page Jan 6, 2024 · 1 revision

The --shell option is a very powerful tool in your prompt engineering. It enables the aia program to do two things that in normally does not do:

  1. access the value of system environment variables (envars) that have the pattern of $USER or ${USER} - the envar must be in all uppercase.

  2. execute shell commands referenced using the pattern $(shell command) where the shell command can be as simple or as complex as need. 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 similiar 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:

  1. tailor the prompt text
  2. provide addition, current information in the prompt text
  3. really mess things up, so be careful!