
Making my aliased commands in zsh better
You can now use Amazon Q Developer directly from your terminal to interact with your files, so let's add some convenience automations.
README.md
file updated is not always the highest priority, so I tried it out with the following prompt to see how past-Cobus did:Can you update the readme based on the code in this repo. Please maintain the Security and License sections at the bottom of the file exactly as they are.
README.md
wasn't rewritten from scratch, Q Dev picked up on the format (using a table), and then added a new row for the missing module (you can see the extra row on line 44 in the code block below):1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Write to filesystem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Path: README.md
Replacing:
- 1 ## Terraform samples
- 2
- 3 Collection of examples of how to use Terraform with AWS.
- 4
- 5 List of modules:
- 6
- 7 | Module | Description|
- 8 |-|-|
- 9 |[bootstrap-aws-account](./modules/bootstrap-aws-account/)|Helps bootstrap a new AWS account to use Terraform by creating the resources needed to store the state file.|
- 10 |[bootstrap-cicd-aws-codebuild](./modules/bootstrap-cicd-aws-codebuild/)|Sets up a CI/CD pipeline for Terraform in a GitHub repo, with workflows to add the plan as a comment on pull requests, and apply changes when a PR is merged using AWS CodeBuild.|
- 11 |[bootstrap-cicd-github-actions](./modules/bootstrap-cicd-github-actions/)|Sets up a CI/CD pipeline for Terraform in a GitHub repo, with workflows to add the plan as a comment on pull requests, and apply changes when a PR is merged using GitHub Actions.|
- 12 |[bootstrap-cloudtrail](./modules/bootstrap-cloudtrail/)|Sets up a basic AWS CloudTrail configuration for the account.|
- 13 |[aws-billing-budget-notification](./modules/aws-billing-budget-notification/)|Sets up an AWS Budget with an email alert.|
- 14
- 15 ## Security
- 16
- 17 See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
- 18
- 19 ## License
- 20
- 21 This library is licensed under the MIT-0 License. See the LICENSE file.
With:
+ 1 ## Terraform samples
+ 2
+ 3 Collection of examples of how to use Terraform with AWS.
+ 4
+ 5 List of modules:
+ 6
+ 7 | Module | Description|
+ 8 |-|-|
+ 9 |[bootstrap-aws-account](./modules/bootstrap-aws-account/)|Helps bootstrap a new AWS account to use Terraform by creating the resources needed to store the state file.|
+ 10 |[bootstrap-cicd-aws-codebuild](./modules/bootstrap-cicd-aws-codebuild/)|Sets up a CI/CD pipeline for Terraform in a GitHub repo, with workflows to add the plan as a comment on pull requests, and apply changes when a PR is merged using AWS CodeBuild.|
+ 11 |[bootstrap-cicd-github-actions](./modules/bootstrap-cicd-github-actions/)|Sets up a CI/CD pipeline for Terraform in a GitHub repo, with workflows to add the plan as a comment on pull requests, and apply changes when a PR is merged using GitHub Actions.|
+ 12 |[bootstrap-cloudtrail](./modules/bootstrap-cloudtrail/)|Sets up a basic AWS CloudTrail configuration for the account.|
+ 13 |[aws-billing-budget-notification](./modules/aws-billing-budget-notification/)|Sets up an AWS Budget with an email alert.|
+ 14 |[temp-ec2-instance](./modules/temp-ec2-instance/)|Creates a temporary EC2 instance with Terraform pre-installed for bootstrapping purposes. Includes VPC, security group, and IAM role configuration.|
+ 15
+ 16 Examples:
+ 17
+ 18 | Example | Description|
+ 19 |-|-|
+ 20 |[bootstrap-new-aws-account](./examples/bootstrap-new-aws-account/)|Example showing how to bootstrap a new AWS account with the necessary Terraform infrastructure.|
+ 21
+ 22 ## Security
+ 23
+ 24 See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
+ 25
+ 26 ## License
+ 27
+ 28 This library is licensed under the MIT-0 License. See the LICENSE file.
Enter y to run this tool, otherwise continue chatting.
~/.bashrc
or ~/.zshrc
. I'm going to group my aliases together in a script per topic or tool, e.g. I'll use q-helpers.sh
for Q Dev, and likely git-helpers.sh
for some git
commands.q-helpers.sh
I have the following:1
2
3
alias q-readme='q chat "Can you update the readme based on the code in this repo. Please maintain the Security and License sections at the bottom of the file exactly as they are. If it makes sense, also include a Mermaid diagram in the Readme.'
alias q-add-license='q chat "Can you please add the SPDX line to all source code files with the appropriate string for the license based on which one has been defined?"
'
and the prompt with double quotes "
.alias add q-readme='q chat "Can you update the readme based on the code in this repo. Please maintain the Security and License sections at the bottom of the file exactly as they are. If it makes sense, also include a Mermaid diagram in the Readme."
alias q-add-license='q chat "Can you please add the SPDX line to all source code files with the appropriate string for the license based on which one has been defined?"
chmod +x q-helpers.sh
. The last step now is to add them to ~/.zshrc
(I use zsh
with oh-my-zsh
):1
2
3
4
5
# Source all files in dotfiles directory
for file in ~/dotfiles/*.sh; do
[ -r "$file" ] && source "$file"
echo "Dotfiles loaded."
done
source ~/.zshrc
, and I can call q-readme
and q-add-license
from anywhere. Thinking about it, I could probably combine a number of instructions in a single prompt to cover a lot of common scenarios... Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.