1376 字
7 分钟
开发者工具箱:提升效率的必备工具
为什么工具如此重要?
工欲善其事,必先利其器。
好的工具可以:
- 提高开发效率 10 倍
- 减少错误发生
- 让工作更有乐趣
本文介绍开发者必备的工具和技巧。
代码编辑器
VS Code
必备插件
代码质量
{ "recommendations": [ "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "streetsidesoftware.code-spell-checker" ]}语言支持
{ "recommendations": [ "golang.go", "ms-python.python", "redhat.java", "vue.volar", "bradlc.vscode-tailwindcss" ]}开发体验
{ "recommendations": [ "eamodio.gitlens", "ms-vscode.hexeditor", "formulahendry.auto-rename-tag", "christian-kohler.path-intellisense" ]}高级配置
{ "editor.formatOnSave": true, "editor.tabSize": 2, "editor.wordWrap": "on", "files.autoSave": "afterDelay", "files.autoSaveDelay": 1000, "terminal.integrated.fontSize": 14, "workbench.colorTheme": "One Dark Pro", "workbench.iconTheme": "material-icon-theme"}有用快捷键
// 命令面板Ctrl/Cmd + Shift + P
// 快速打开文件Ctrl/Cmd + P
// 多光标Ctrl/Cmd + D
// 跳转定义F12
// 重命名符号F2
// 格式化文档Shift + Alt + F其他编辑器
Neovim:极客的选择,配置灵活 IntelliJ IDEA:Java 开发神器 WebStorm:前端开发神器
终端工具
Zsh + Oh My Zsh
# 安装 Zshsudo apt install zsh
# 安装 Oh My Zshsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 必装插件# ~/.zshrcplugins=(git zsh-autosuggestions zsh-syntax-highlighting)Starship Prompt
# 安装 Starshipcurl -fsSL https://starship.rs/install.sh | bash
# 配置 ~/.zshrceval "$(starship init zsh)"
# 配置 ~/.config/starship.toml[character]success_symbol = "➜"error_symbol = "✗"
[git_branch]symbol = "🌱 "
[nodejs]symbol = "⬢ "Tmux
# 安装sudo apt install tmux
# 配置 ~/.tmux.confset -g base-index 1set -g pane-base-index 1set -g status-bg blackset -g status-fg whiteset -g status-left '#[fg=green]#S 'set -g status-right '#H %H:%M '快捷键
# 新建会话Ctrl + b, c
# 切换会话Ctrl + b, s
# 分割窗口Ctrl + b, % # 水平Ctrl + b, " # 垂直
# 切换窗口Ctrl + b, nFZF
# 安装git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf~/.fzf/install
# 使用Ctrl + R # 历史命令搜索Ctrl + T # 文件搜索Alt + C # 目录切换Git 工具
Lazygit
# 安装sudo apt install lazygit
# 使用lazygit特性:
- 可视化 Git 操作
- 交互式添加文件
- 快速提交和推送
Git Hooks
# 安装 Huskynpm install husky --save-devnpx husky install
# 添加 commit hooknpx husky add .husky/pre-commit "npm test"
# 添加 commitlintnpm install @commitlint/cli @commitlint/config-conventional --save-devGit Aliases
[alias] st = status co = checkout br = branch ci = commit unstage = reset HEAD -- last = log -1 HEAD visual = log --graph --oneline --all --decorateAPI 工具
Insomnia
替代 Postman 的更轻量选择:
- 干净的界面
- 更好的性能
- 支持 GraphQL
HTTPie
# 安装pip install httpie
# 使用http GET https://api.example.com/users
http POST https://api.example.com/users name=John email=john@example.com
http PUT https://api.example.com/users/123 email=new-email@example.comCurl 技巧
# 基本请求curl https://api.example.com/users
# 带认证curl -H "Authorization: Bearer token" https://api.example.com/users
# POST JSONcurl -X POST -H "Content-Type: application/json" \ -d '{"name":"John"}' \ https://api.example.com/users
# 上传文件curl -F "file=@document.pdf" https://api.example.com/upload
# 保存响应curl -o output.json https://api.example.com/data调试工具
Chrome DevTools
快捷键
F12 打开开发者工具Ctrl/Cmd + Shift + C 元素选择器Ctrl/Cmd + Shift + J 控制台Ctrl/Cmd + Shift + I 开发者工具面板
- Elements:元素和样式
- Console:控制台和日志
- Sources:调试和断点
- Network:网络请求
- Performance:性能分析
- Memory:内存分析
- Application:应用数据
VS Code 调试器
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceFolder}/index.js" }, { "type": "chrome", "request": "launch", "name": "Launch Chrome", "url": "http://localhost:3000", "webRoot": "${workspaceFolder}" } ]}性能分析
Lighthouse
# 安装npm install -g lighthouse
# 使用lighthouse https://example.com --viewWebPageTest
# 在线使用https://www.webpagetest.org/
# APIcurl "https://www.webpagetest.org/runtest.php?url=https://example.com&k=YOUR_API_KEY"Profiling Tools
CPU Profiling
const profiler = require('v8-profiler');profiler.startProfiling('cpu-profile');
// 你的代码doSomething();
profiler.stopProfiling('cpu-profile');Memory Profiling
// Chrome DevTools// 1. 打开 Memory 面板// 2. 选择 "Heap snapshot"// 3. 拍快照// 4. 分析内存泄漏数据库工具
DBeaver
支持多种数据库:
- MySQL / PostgreSQL / SQLite
- MongoDB / Redis
- Oracle / SQL Server
psql 技巧
# 连接psql -h localhost -U username -d database
# 导出pg_dump -h localhost -U username database > backup.sql
# 导入psql -h localhost -U username -d database < backup.sql
# 查看表结构\d table_name容器工具
Docker Compose
version: '3.8'
services: app: build: . ports: - "3000:3000" environment: - NODE_ENV=development volumes: - .:/app - /app/node_moduleskubectl 技巧
# 上下文管理kubectl config use-context context-namekubectl config get-contexts
# 快速查看kubectl get pods -wkubectl describe pod pod-namekubectl logs -f pod-name
# 进入容器kubectl exec -it pod-name -- /bin/sh
# 端口转发kubectl port-forward pod-name 8080:3000监控工具
Prometheus + Grafana
global: scrape_interval: 15s
scrape_configs: - job_name: 'node' static_configs: - targets: ['localhost:9100']htop / nload
# 系统监控htop
# 网络监控nload自动化工具
Make
# Makefile.PHONY: install test build
install: npm install
test: npm test
build: npm run build
run: npm run dev
clean: rm -rf dist node_modules# 使用make installmake testmake buildGitHub Actions
name: CI
on: push: branches: [ main ] pull_request:
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - run: npm ci - run: npm test文档工具
Markdown 增强
VS Code 插件
{ "recommendations": [ "yzhang.markdown-all-in-one", "shd101wyy.markdown-preview-enhanced", "bierner.markdown-mermaid" ]}Mermaid 图表
```mermaidgraph TD A[开始] --> B{条件} B -->|真| C[操作1] B -->|假| D[操作2] C --> E[结束] D --> E### Swagger / OpenAPI
```yamlopenapi: 3.0.0info: title: My API version: 1.0.0
paths: /users: get: summary: Get users responses: '200': description: Success搜索工具
Ripgrep (rg)
# 安装sudo apt install ripgrep
# 使用rg "function" ./src
# 忽略文件rg "function" ./src --glob "!*.test.js"
# 上下文rg "function" ./src -C 3Fd
# 安装sudo apt install fd-find
# 使用fd pattern
# 扩展名过滤fd ".js" ./src远程工具
SSH Config
Host server HostName 192.168.1.100 User username Port 22 IdentityFile ~/.ssh/id_rsa# 使用ssh serverTmux
远程开发必备:
- 会话保持
- 多窗口
- 可视化
学习工具
Anki
使用间隔重复学习技术:
- 学习编程概念
- 记忆快捷键
- 复习最佳实践
Devhints
快速参考备忘单:
https://devhints.io/总结
好的工具可以大幅提升效率:
编辑器:VS Code + 必备插件
终端:Zsh + Oh My Zsh + Starship
Git:Lazygit + Git Hooks
API:Insomnia + HTTPie
调试:Chrome DevTools + VS Code 调试器
性能:Lighthouse + Profiling Tools
数据库:DBeaver + psql
容器:Docker + kubectl
监控:Prometheus + Grafana
自动化:Make + GitHub Actions
记住:工具是为我们服务的,选择适合你的工具,持续学习和优化你的工具链。
相关文章:
开发者工具箱:提升效率的必备工具
https://www.599.red/posts/developer-tools-guide/