1 Commits

Author SHA1 Message Date
Martin Blazik
30c56f67f8 fish shell configuration 2025-04-25 09:54:13 +02:00
21 changed files with 29 additions and 235 deletions

View File

@@ -1,4 +0,0 @@
#!/bin/bash
tr '[:lower:]' '[:upper:]' "$@"

View File

@@ -1,75 +0,0 @@
#!/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)

View File

@@ -1,5 +0,0 @@
#!/bin/bash
vim "$@" --cmd 'au VimLeave * :!clear'
clear

6
conf/fish/lws.fish Normal file
View File

@@ -0,0 +1,6 @@
# ~/.config/fish/config.fish
# ~/.config/fish/conf.d/
# cp $LWS/conf/fish/lws.fish $HOME/.config/fish/conf.d/
set -U fish_prompt_pwd_dir_length 0

View File

@@ -1,21 +0,0 @@
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config
[boot]
systemd=false
[user]
default=lachtan
[automount]
enabled = true
[network]
generateHosts = true
generateResolvConf = false
[interop]
enabled = false
appendWindowsPath = false
[gpu]
enabled = true

3
fishrc
View File

@@ -1,3 +0,0 @@
for file in (dirname (status -f))/rc.fish/*.fish
source $file
end

View File

@@ -1,5 +1,4 @@
# Linux Workspace Functions
# shellcheck shell=bash
if [ -z "$time_ms" ]; then
readonly time_ms='date +%s%3N'
@@ -135,7 +134,3 @@ function true_false() {
# [[ "${1,,}" =~ ^(1|true|yes)$ ]]
[[ "${1@L}" =~ ^(1|true|yes)$ ]]
}
function is_wsl() {
grep -q -i wsl /proc/version
}

View File

@@ -2,29 +2,11 @@
set -E -o errexit -o nounset -o pipefail
function install_lws() {
local LWS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
if grep -q -e "source.*$LWS_DIR/bashrc" $HOME/.bashrc; then
echo "SKIP: Linux Workspace configuration already exists in $HOME/.bashrc !"
if grep -q -e 'source\s+.*/linux-workspace/bashrc\s*$' $HOME/.bashrc; then
echo "Linux Workspace configuration already exists in .bashrc !"
exit 1
else
readonly SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
echo "Adding to $HOME/.bashrc"
echo "source '$LWS_DIR/bashrc'" >> "$HOME/.bashrc"
echo "source '$SCRIPT_DIR/bashrc'" >> "$HOME/.bashrc"
fi
local FISH_CONF_DIR="$HOME/.config/fish"
local FISH_CONF_LWS="$FISH_CONF_DIR/conf.d/lws.fish"
if [[ -d "$FISH_CONF_DIR" ]]; then
if [[ -f "$FISH_CONF_LWS" ]]; then
echo "SKIP: Linux Workspace configuration already exists in $FISH_CONF_LWS !"
else
echo "Adding to $FISH_CONF_LWS"
echo "source $LWS_DIR/fishrc" > "$FISH_CONF_LWS"
fi
else
echo "Fish configuration directory not found, skipping fish setup."
fi
}
install_lws

View File

@@ -1,9 +0,0 @@
#!/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

View File

@@ -1,8 +0,0 @@
#!/bin/bash
# https://github.com/google-gemini/gemini-cli
set -E -o errexit -o nounset -o pipefail
set -x
npm install -g @google/gemini-cli

View File

@@ -1,10 +0,0 @@
#!/bin/bash
# https://github.com/nvm-sh/nvm
set -E -o errexit -o nounset -o pipefail
set -x
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
nvm install node
nvm use node

View File

@@ -1,5 +0,0 @@
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,2 +1 @@
prepend_path_try "$HOME/.local/bin"
prepend_path_try "$HOME/bin"

View File

@@ -1,11 +1,5 @@
alias nop=':'
# Long format, human-readable, with indicators
alias ll='ls -lhF'
# Same as ll but including hidden files
alias la='ls -lhAF'
alias exit-when-error='set -o errexit'
alias exit-when-unset-variable='set -o nounset'
alias exit-when-pipe-fail='set -o pipefail'
@@ -15,7 +9,6 @@ alias clws='cd $LWS'
alias chs=cheatsheet
alias dc=docker-compose
alias pc=podman-compose
alias dcl='dcm logs'
alias dcfilter="sed -r 's/^[^|]+\| //g'"

View File

@@ -1 +1,3 @@
source_try "$HOME/.cargo/env"
if [[ -f "$HOME/.cargo/env" ]]; then
source "$HOME/.cargo/env"
fi

View File

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

View File

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

View File

@@ -1,8 +0,0 @@
NVM_DIR="$HOME/.nvm"
if [ -d "$NVM_DIR" ]; then
export NVM_DIR
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
else
unset NVM_DIR
fi

View File

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

View File

@@ -1,51 +1,9 @@
# Start ssh agent for private key
function _log() {
xlog "[ssh-agent] $*"
}
_SSH_AGENT_NO_KEYS=1
_SSH_AGENT_NOT_RUNNING=2
for key in id_ecdsa id_rsa; do
key_filename="$HOME/.ssh/$key"
if [ -f "$key_filename" ]; then
_log "SSH key: $key_filename"
if is_wsl; then
_log "WSL ON"
if [ -z "$SSH_AUTH_SOCK" ]; then
export SSH_AUTH_SOCK=$HOME/.ssh/ssh-agent.sock
fi
_log "SSH_AUTH_SOCK: $SSH_AUTH_SOCK"
ssh-add -L &> /dev/null
ssh_add_status=$?
if [[ -S "$SSH_AUTH_SOCK" && $ssh_add_status -eq $_SSH_AGENT_NOT_RUNNING ]]; then
_log "SSH agent does not running, delete $SSH_AUTH_SOCK"
rm -f "$SSH_AUTH_SOCK"
fi
if [[ ! -S "$SSH_AUTH_SOCK" || $ssh_add_status -eq $_SSH_AGENT_NOT_RUNNING ]]; then
_log "Starting ssh-agent"
eval "$(ssh-agent -s -a "$SSH_AUTH_SOCK")"
fi
ssh-add -L &> /dev/null
ssh_add_status=$?
if [[ $ssh_add_status -eq $_SSH_AGENT_NO_KEYS ]]; then
_log "Adding SSH key to agent"
ssh-add "$key_filename"
fi
else
eval "$(keychain --eval --quiet --agents ssh $key)"
fi
if [ -f $key_filename ]; then
eval $(keychain --eval --quiet --agents ssh $key)
break
fi
done

10
rc/wsl.sh Normal file
View File

@@ -0,0 +1,10 @@
function is_wsl()
{
grep -q -i wsl /proc/version
}
if is_wsl; then
prepend_path_try "$HOME/.local/bin"
append_path_try "$HOME/.arkade/bin"
append_path_try "$HOME/.cargo/bin"
fi