Claude Max 容易被封?两个 Claude Pro 账号实现双开
Claude Code Cli 支持通过 CLAUDE_CONFIG_DIR 指定配置目录。
默认情况下,直接在终端输入 claude,使用的是 ~/.claude 目录。这里保存着账号登录状态、配置、历史记录、插件和会话等信息。
所以,想使用第二个 Claude Pro 账号,只需要给它指定一个独立的配置目录即可。
1. 配置第二个账号
打开 ~/.zshrc,添加一个别名:
▼bash复制代码alias claude-work='CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude'
保存后,执行:
▼bash复制代码source ~/.zshrc
2. 如何使用?
以后在终端中:
▼bash复制代码claude # 使用第一个账号 claude-work # 使用第二个账号
第一次执行 claude-work 时,Claude Code 会在 ~/.claude-work 目录下初始化配置,并要求你重新登录第二个账号。
之后,你甚至可以同时打开两个终端窗口:
- 终端 A:使用第一个 Claude Pro 账号。
- 终端 B:使用第二个 Claude Pro 账号。
两个账号各自拥有独立的登录状态、配置和会话记录,互不干扰。
3. 为什么这样就可以?
关键在于这条命令:
▼bash复制代码CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude
Linux 和 macOS 支持在命令前设置环境变量,这个变量只对当前启动的进程生效。但是这个原理不重要,用起来才是最重要的。
4. 如何单独看额度
这里可以用到 Claude Code 的 Status Line 这个功能,我们可以在 Status 上面看到当前的模型、上下文长度、5H 剩余、周额度等等
先来看一下效果:

第一行是当前模型、思考强度、上下文占用和缓存命中率,第二行是 5 小时额度和 7 天额度的剩余量,以及多久后重置。
脚本依赖 jq。macOS 可以这样装:
▼bash复制代码brew install jq
把下面的内容保存为 ~/.claude/statusline.sh:
▼bash复制代码#!/usr/bin/env bash # Claude Code status line. Requires jq. set -u # Claude Code sends one JSON object to stdin on every refresh. IFS=$'\t' read -r model effort ctx hit used5 reset5 used7 reset7 < <( jq -r ' def percent: if type == "number" then ([0, ([100, .] | min)] | max | round) else "NA" end; [ (.model.display_name // "Unknown"), (.effort.level // "N/A"), (.context_window.used_percentage | percent), (.prompt_cache.hit_ratio | if type == "number" then (. * 100 | round) else "NA" end), (.rate_limits.five_hour.used_percentage | percent), (.rate_limits.five_hour.resets_at // "NA"), (.rate_limits.seven_day.used_percentage | percent), (.rate_limits.seven_day.resets_at // "NA") ] | @tsv ' ) RESET=$'\033[0m' DIM=$'\033[2m' MODEL_COLOR=$'\033[1;35m' CYAN=$'\033[36m' SEPARATOR=$'\033[38;2;130;130;130m' TRACK=$'\033[38;2;120;120;120m' GREEN=$'\033[32m' YELLOW=$'\033[33m' RED=$'\033[31m' percent_text() { if [[ $1 =~ ^[0-9]+$ ]]; then printf '%d%%' "$1"; else printf '%s' '--%'; fi } left_text() { if [[ $1 =~ ^[0-9]+$ ]]; then printf '%d%%' "$((100 - $1))"; else printf '%s' '--%'; fi } reset_after() { local ts=$1 seconds days hours mins if [[ ! $ts =~ ^[0-9]+([.][0-9]+)?$ ]]; then printf '%s' '--'; return; fi seconds=$(( ${ts%%.*} - NOW )) (( seconds < 0 )) && seconds=0 days=$((seconds / 86400)) hours=$(((seconds % 86400) / 3600)) mins=$(((seconds % 3600) / 60)) if (( days > 0 )); then printf '%dd %dh' "$days" "$hours" elif (( hours > 0 )); then printf '%dh %dm' "$hours" "$mins" else printf '%dm' "$mins" fi } # Gradient uses stable, full-width block characters: no fractional glyphs. context_bar() { local pct=$1 width=20 filled=0 i pos r g b offset if [[ $pct =~ ^[0-9]+$ ]]; then filled=$(((pct * width + 50) / 100)); fi for ((i = 0; i < width; i++)); do if (( i >= filled )); then printf '%s░' "$TRACK" continue fi pos=$((i * 100 / (width - 1))) if ((pos <= 50)); then r=$(( 0 + 220 * pos / 50 )) g=200 b=$(( 80 - 80 * pos / 50 )) else offset=$((pos - 50)) r=220 g=$(( 200 - 160 * offset / 50 )) b=$(( 20 * offset / 50 )) fi printf '\033[38;2;%d;%d;%dm█' "$r" "$g" "$b" done printf '%s' "$RESET" } usage_color() { if [[ ! $1 =~ ^[0-9]+$ ]] || (( $1 < 70 )); then printf '%s' "$GREEN" elif (( $1 < 90 )); then printf '%s' "$YELLOW" else printf '%s' "$RED"; fi } NOW=$(date +%s) ctx_label=$(percent_text "$ctx") hit_label=$(percent_text "$hit") five_left=$(left_text "$used5") seven_left=$(left_text "$used7") five_reset=$(reset_after "$reset5") seven_reset=$(reset_after "$reset7") ctx_color=$(usage_color "$ctx") five_color=$(usage_color "$used5") seven_color=$(usage_color "$used7") printf '%s[%s · %s]%s ' "$MODEL_COLOR" "$model" "$effort" "$RESET" context_bar "$ctx" printf ' %s%s%s %s│%s %sHit%s %s%s\n' "$ctx_color" "$ctx_label" "$RESET" "$SEPARATOR" "$RESET" "$CYAN" "$RESET" "$CYAN" "$hit_label" printf '5h %s%s%s left %s·%s reset %s %s│%s 7d %s%s%s left %s·%s reset %s\n' \ "$five_color" "$five_left" "$RESET" "$DIM" "$RESET" "$five_reset" "$SEPARATOR" "$RESET" \ "$seven_color" "$seven_left" "$RESET" "$DIM" "$RESET" "$seven_reset"
然后在 ~/.claude/settings.json 里加上:
▼json复制代码{ "statusLine": { "type": "command", "command": "bash \"$HOME/.claude/statusline.sh\"" } }
第二个账号用的是 ~/.claude-work/settings.json,同样加上这段。两个账号可以共用 ~/.claude/statusline.sh,额度是 Claude Code 按当前登录账号传给脚本的,所以各自显示各自的用量。
评论
问答助学
相关内容
0个评论
全部评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
内容推荐
作为一个从业人员,如果使用AI,也是用问答的形式,那基本是要out了。一定要用上Agent化,把背景知识作为上下文管理起来,而且让Agent自进化。
5
你有没有想过一个问题:今天你用 Claude,明天用 Codex,后天又出现一个更聪明的 AI。每换一个 AI,你是不是都要重新介绍一遍自己?你的工作经历、知识积累、思考方式、生活习惯和个人偏好,散落在不同的工具、平台和聊天记录里。AI 越来越聪明,却始终不够了解你。我一直觉得,AI 时代真正值得积累的,不只是模型能力,而是属于每个人自己的 Personal Context。所以,我把这个想法做成
1
这 3 年 AI Agent 到底进化了啥?万字大白话,一次讲透!
8
DeepSeekHarness插件
3
烧了上万块,我让 AI 做了 500 多个网站!
6
