编辑配置文件和文本文件
Aider 不仅适用于代码编辑,在修改几乎所有类型的文本文件时都能提供很大帮助。 你可以使用 aider 来修改 shell 和 ssh 设置、 Dockerfile 或者几乎任何配置文件或文档文件。
以下是修改常见配置/文本文件的一些实用示例:
Shell 配置
$ aider .bashrc
已将 .bashrc 加入聊天会话。
添加一个别名 ‘ll’,用于列出所有文件的详细信息并以人类可读格式显示。同时更新 PATH 以包含 uv 安装的工具。
+ alias ll='ls -alh'
+ export PATH="$PATH:$HOME/.local/bin:$PATH"
SSH 配置
$ aider ~/.ssh/config
已将 config 加入聊天会话。
创建一个名为 ‘my-server’ 的主机条目,使用 bastion.example.com 作为跳板机
+ Host my-server
+ HostName 192.168.1.100
+ User deploy
+ Port 2222
+ IdentityFile ~/.ssh/deploy_key
+ ProxyJump bastion.example.com
Docker 配置
$ aider Dockerfile docker-compose.yml
已将 Dockerfile 和 docker-compose.yml 加入聊天会话。
设置非 root 用户并启用健康检查
+ USER appuser
+ HEALTHCHECK --interval=30s --timeout=3s \
+ CMD curl -f http://localhost:8000/health || exit 1
暴露 5432 端口并为 postgres 数据添加卷
services:
postgres:
image: postgres:15
+ ports:
+ - "5432:5432"
+ volumes:
+ - pgdata:/var/lib/postgresql/data
Git 配置
$ aider .gitconfig
已将 .gitconfig 加入聊天会话。
设置默认推送行为为当前分支并启用彩色 UI
+ [push]
+ default = current
+ [color]
+ ui = auto
系统配置
$ aider /etc/hosts # 可能需要 sudo
已将 hosts 加入聊天会话。
通过将跟踪域名指向 127.0.0.1 来屏蔽它们
+ 127.0.0.1 ads.example.com
+ 127.0.0.1 track.analytics.co
编辑器配置
$ aider .vimrc
已将 .vimrc 添加到聊天会话。
启用行号并为 Python 设置 4 空格缩进
+ set number
+ autocmd FileType python set tabstop=4 shiftwidth=4 expandtab
VSCode 配置
$ aider settings.json
已将 settings.json 添加到聊天会话。
启用保存时自动格式化并设置默认格式化工具
+ "editor.formatOnSave": true,
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
Markdown 文档
$ aider README.md
已将 README.md 添加到聊天会话。
添加安装章节,包含 brew 和 pip 选项
+ ## 安装
+ ```
+ # Homebrew
+ brew install cool-app-10k
+
+ # PyPI
+ pipx install cool-app-10k
+ ```
XML 配置
$ aider pom.xml
已将 pom.xml 添加到聊天会话。
添加测试范围的 JUnit 5 依赖
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>5.9.2</version>
+ <scope>test</scope>
+ </dependency>