9 Commits

Author SHA1 Message Date
lachtan obecny
4997598194 Fix: dircolors loading 2026-02-20 06:38:10 +01:00
lachtan obecný
01cefdc6fd InitCLAUDE.ms 2026-02-20 06:38:10 +01:00
lachtan
c5ba20c814 xclaude refactor with claude 2026-02-19 20:25:41 +01:00
lachtan
161c2c2291 xclaude - alternativa k ollama launch 2026-02-19 20:16:48 +01:00
lachtan obecny
dfca731f77 fish initialization remake 2026-01-27 20:07:30 +01:00
lachtan obecny
2b9d0835f0 Go and OpenCode path 2026-01-21 06:49:12 +01:00
lachtan
07e034d5f4 rename npm.sh to nvm-npm.sh 2026-01-15 05:44:09 +00:00
lachtan
7884d4fb61 install claude code 2026-01-15 05:43:27 +00:00
lachtan
ac6c6203c3 add podman-compose alias 2026-01-15 05:28:36 +00:00
12 changed files with 130 additions and 12 deletions

33
CLAUDE.md Normal file
View File

@@ -0,0 +1,33 @@
# CLAUDE.md
Dotfiles & workstation automation for Linux, macOS, WSL. `bashrc` loads `rc/*.sh` (ordered by prefix) and adds `bin/` to PATH. `$LWS` points to repo root.
## Directory Layout
- `rc/` — Shell init files, loaded in `0X-name.sh` order. Per-tool env setup goes here.
- `install/` — Idempotent one-off installer scripts (run manually).
- `bin/` — Scripts auto-added to PATH. New CLI tools go here.
- `scripts/` — Setup scripts NOT on PATH (git-config, docker fixes, gnome config).
- `conf/` — Tool configs (vim, WireGuard, WSL).
- `functions.sh` — Core lib: `append_path`, `prepend_path`, `set_uniq_path`, `source_directory_sh`, `is_fast_init`/`is_slow_init`, WSL detection, debug logging.
## Conventions
All new bash scripts MUST use:
```bash
#!/usr/bin/env bash
set -E -o errexit -o nounset -o pipefail
```
Before writing shell code, check `functions.sh` for existing helper functions (e.g. `can_run`, `append_path_try`, `source_try`) and prefer them over raw commands.
RC files MUST guard slow tools and check availability:
```bash
if is_slow_init && can_run pyenv; then
# initialize pyenv
fi
```
Installers (`install/*.sh`) MUST be idempotent — check before installing.
Env vars: `LWS_FAST=1` skips slow tools, `LWS_DEBUG=1` enables debug logging.

75
bin/xclaude Executable file
View File

@@ -0,0 +1,75 @@
#!/usr/bin/env python3
# https://code.claude.com/docs/en/settings
import argparse
import os
import sys
import urllib.parse
env = os.environ
def die(msg):
print(f"Error: {msg}", file=sys.stderr)
sys.exit(1)
def validate_url(url):
parsed = urllib.parse.urlparse(url)
if parsed.scheme not in ("http", "https"):
die(f"invalid URL scheme '{parsed.scheme}' in --url (expected http or https)")
parser = argparse.ArgumentParser(
prog="xclaude",
description="Run Claude Code with any OpenAI-compatible API backend.",
epilog="""\
Environment variables (overridable by arguments):
CLAUDE_URL - API base URL (e.g. https://openrouter.ai/api/v1)
CLAUDE_TOKEN - API token/key
CLAUDE_MODEL - model name
If neither URL nor token is set, defaults to Ollama:
OLLAMA_HOST - Ollama server address (default: nvidia.hell), or use --host
OLLAMA_MODEL - Ollama model (default: glm-5:cloud)
Any extra arguments are passed through directly to the claude CLI.
Examples:
xclaude
xclaude --model qwen3-coder
xclaude --url https://openrouter.ai/api/v1 --token sk-XXX --model openai/gpt-4o
""",
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument("--url", default=env.get("CLAUDE_URL", ""))
parser.add_argument("--token", default=env.get("CLAUDE_TOKEN", ""))
parser.add_argument("--model", default=env.get("CLAUDE_MODEL", ""))
parser.add_argument("--host", default=env.get("OLLAMA_HOST", "nvidia.hell"))
args, rest = parser.parse_known_args()
env["DISABLE_TELEMETRY"] = "1"
is_external_api = bool(args.url or args.token)
if is_external_api:
if not args.url:
die("no URL specified (--url or CLAUDE_URL)")
validate_url(args.url)
if not args.token:
die("no token specified (--token or CLAUDE_TOKEN)")
if not args.model:
die("no model specified (--model or CLAUDE_MODEL)")
env["ANTHROPIC_BASE_URL"] = args.url
env["ANTHROPIC_API_KEY"] = args.token
# Remove Ollama auth token if switching to external API
env.pop("ANTHROPIC_AUTH_TOKEN", None)
model = args.model
else:
host = args.host
model = args.model or env.get("OLLAMA_MODEL", "glm-5:cloud")
env["ANTHROPIC_BASE_URL"] = f"http://{host}:11434"
env["ANTHROPIC_AUTH_TOKEN"] = "ollama"
env.pop("ANTHROPIC_API_KEY", None)
cmd = ["claude", "--model", model] + rest
os.execvp("claude", cmd)

14
fishrc
View File

@@ -1,11 +1,3 @@
# ~/.config/fish/config.fish for file in (dirname (status -f))/rc.fish/*.fish
# echo "source $LWS/fishrc" > $__fish_config_dir/conf.d/lws.fish source $file
end
# $__fish_config_dir/conf.d (by default, ~/.config/fish/conf.d/)
# $__fish_sysconf_dir/conf.d (by default, /etc/fish/conf.d/)
set -gx PAGER less
set -g fish_prompt_pwd_dir_length 0
# set -g fish_autosuggestion_enabled 0
# fish_config theme choose "fish default"

View File

@@ -1,4 +1,5 @@
# Linux Workspace Functions # Linux Workspace Functions
# shellcheck shell=bash
if [ -z "$time_ms" ]; then if [ -z "$time_ms" ]; then
readonly time_ms='date +%s%3N' readonly time_ms='date +%s%3N'

9
install/claude-code.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
# https://code.claude.com/docs/en/setup
set -E -o errexit -o nounset -o pipefail
set -x
curl -fsSL https://claude.ai/install.sh | bash

5
rc.fish/01-init.fish Normal file
View File

@@ -0,0 +1,5 @@
set -gx PAGER less
set -g fish_prompt_pwd_dir_length 0
# set -g fish_autosuggestion_enabled 0
# fish_config theme choose "fish default"

View File

View File

@@ -15,6 +15,7 @@ alias clws='cd $LWS'
alias chs=cheatsheet alias chs=cheatsheet
alias dc=docker-compose alias dc=docker-compose
alias pc=podman-compose
alias dcl='dcm logs' alias dcl='dcm logs'
alias dcfilter="sed -r 's/^[^|]+\| //g'" alias dcfilter="sed -r 's/^[^|]+\| //g'"

View File

@@ -5,7 +5,7 @@
#COLORS_FILE="$LWS/conf/dircolors/ansi-light.dircolors" #COLORS_FILE="$LWS/conf/dircolors/ansi-light.dircolors"
COLORS_FILE="$LWS/conf/dircolors/dracula.dircolors" COLORS_FILE="$LWS/conf/dircolors/dracula.dircolors"
if [[ -f "$COLORS_FILE" ]]; then if can_run dircolors && [[ -f "$COLORS_FILE" ]]; then
xlog "Loading colors $COLORS_FILE" xlog "Loading colors $COLORS_FILE"
eval "$(dircolors "$COLORS_FILE")" eval "$(dircolors "$COLORS_FILE")"
else else

1
rc/go.sh Normal file
View File

@@ -0,0 +1 @@
append_path_try "$HOME/.local/go/bin"

1
rc/opencode.sh Normal file
View File

@@ -0,0 +1 @@
append_path_try "$HOME/.opencode/bin"