Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/collector/claude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ pub struct ClaudeCollector {

impl ClaudeCollector {
pub fn new() -> Self {
let home = dirs::home_dir().unwrap_or_default();
let base = std::env::var("CLAUDE_CONFIG_DIR")
.map(PathBuf::from)
.unwrap_or_else(|_| dirs::home_dir().unwrap_or_default().join(".claude"));
Self {
sessions_dir: home.join(".claude").join("sessions"),
projects_dir: home.join(".claude").join("projects"),
sessions_dir: base.join("sessions"),
projects_dir: base.join("projects"),
transcript_cache: HashMap::new(),
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/collector/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ pub fn read_rate_limits() -> Vec<RateLimitInfo> {
let mut results = Vec::new();

// Claude Code: read from StatusLine hook output file
if let Some(claude_dir) = dirs::home_dir().map(|h| h.join(".claude")) {
if let Some(claude_dir) = std::env::var("CLAUDE_CONFIG_DIR")
.ok()
.map(PathBuf::from)
.or_else(|| dirs::home_dir().map(|h| h.join(".claude")))
{
let path = claude_dir.join(CLAUDE_RATE_FILE);
if let Some(info) = read_rate_file(&path, "claude") {
results.push(info);
Expand Down
8 changes: 5 additions & 3 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ if fh:
sd = rl.get('seven_day')
if sd:
out['seven_day'] = {'used_percentage': sd.get('used_percentage', 0), 'resets_at': sd.get('resets_at', 0)}
home = os.path.expanduser('~')
with open(os.path.join(home, '.claude', 'abtop-rate-limits.json'), 'w') as f:
config_dir = os.environ.get('CLAUDE_CONFIG_DIR', os.path.join(os.path.expanduser('~'), '.claude'))
with open(os.path.join(config_dir, 'abtop-rate-limits.json'), 'w') as f:
json.dump(out, f)
" "$INPUT" 2>/dev/null
"#;

fn claude_dir() -> PathBuf {
dirs::home_dir().unwrap_or_default().join(".claude")
std::env::var("CLAUDE_CONFIG_DIR")
.map(PathBuf::from)
.unwrap_or_else(|_| dirs::home_dir().unwrap_or_default().join(".claude"))
}

fn script_path() -> PathBuf {
Expand Down
Loading