Compare commits
1 Commits
f8a61e9290
...
claude
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33813e596a |
@@ -1,64 +0,0 @@
|
|||||||
---
|
|
||||||
paths:
|
|
||||||
- "**/*.sh"
|
|
||||||
- "bashrc"
|
|
||||||
- "bin/*"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Bash Readability Style
|
|
||||||
|
|
||||||
The primary goal is code that is **easy to understand at a glance**. Write bash that reads naturally, follows established conventions, and doesn't require the reader to puzzle over clever tricks. Favor clarity and well-known idioms over brevity.
|
|
||||||
|
|
||||||
Complements CLAUDE.md. Does not repeat rules already defined there.
|
|
||||||
|
|
||||||
## Formatting
|
|
||||||
|
|
||||||
- 2-space indentation, no tabs
|
|
||||||
- `then`/`do` on same line: `if cond; then` / `for x in list; do`
|
|
||||||
- Blank lines between logical sections; no blanks between tightly coupled statements
|
|
||||||
- Long pipe chains: one command per line with leading `|`
|
|
||||||
|
|
||||||
## Naming
|
|
||||||
|
|
||||||
- `UPPER_CASE` — exported env vars and constants
|
|
||||||
- `snake_case` — local variables and function names
|
|
||||||
- `verb_noun` pattern for functions: `set_ps1_prompt`, `docker_aws_login`
|
|
||||||
- Meaningful names, no single letters except loop counters (`i`, `f`)
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
```bash
|
|
||||||
function do_thing() {
|
|
||||||
local name="$1"
|
|
||||||
local count="${2:-0}"
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- Always `function name() {` declaration style
|
|
||||||
- Always `local` for function variables, assigned on declaration line
|
|
||||||
- Name parameters immediately: `local filename="$1"` — no raw `$1` in logic
|
|
||||||
- Default values via `${VAR:-default}`
|
|
||||||
- Guard clauses with early `return` over deep nesting
|
|
||||||
- Keep functions focused — single responsibility
|
|
||||||
|
|
||||||
## Syntax Preferences
|
|
||||||
|
|
||||||
- `[[ ]]` over `[ ]` for conditionals
|
|
||||||
- `(( ))` for arithmetic comparisons
|
|
||||||
- `$(command)` for substitution, never backticks
|
|
||||||
- Double quotes around expansions: `"$var"`, `"${array[@]}"`
|
|
||||||
- Single quotes for literals that must not expand
|
|
||||||
- `printf` over `echo` when output contains escapes or format strings
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
- Long options for clarity: `--recursive` not `-r` (common test flags `-f`, `-d`, `-e` are fine)
|
|
||||||
- Redirect stderr: `> /dev/null 2>&1`
|
|
||||||
- `# shellcheck shell=bash` at top of sourced (non-executable) files
|
|
||||||
|
|
||||||
## Comments
|
|
||||||
|
|
||||||
- Minimal — explain *why*, not *what*
|
|
||||||
- URL reference when pattern comes from external source
|
|
||||||
- No banner/divider comments
|
|
||||||
@@ -7,7 +7,6 @@ insert_final_newline = true
|
|||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = space
|
||||||
max_line_length = 120
|
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
@@ -15,6 +14,7 @@ indent_size = 2
|
|||||||
|
|
||||||
[*.{java,kt,kts}]
|
[*.{java,kt,kts}]
|
||||||
continuation_indent_size = 4
|
continuation_indent_size = 4
|
||||||
|
max_line_length = 120
|
||||||
wildcard_import_limit = 99
|
wildcard_import_limit = 99
|
||||||
|
|
||||||
[*.xml]
|
[*.xml]
|
||||||
|
|||||||
357
CLAUDE.md
357
CLAUDE.md
@@ -1,56 +1,341 @@
|
|||||||
# Linux Workspace
|
# Linux Workspace - Project Documentation
|
||||||
|
|
||||||
Dotfiles & workstation automation for Linux, macOS, WSL. `bashrc` loads `rc/*.sh` (ordered by prefix)
|
## Overview
|
||||||
and adds `bin/` to PATH. `$LWS` points to repo root.
|
|
||||||
|
|
||||||
## Directory Layout
|
**Linux Workspace** is a comprehensive shell configuration and utility toolkit designed to quickly configure new Linux machines with development tools, environment initialization, and useful utility scripts. It provides a modular, source-able bootstrap system for both bash and fish shells.
|
||||||
|
|
||||||
- `rc/` — Shell init files, loaded in `0X-name.sh` order. Per-tool env setup goes here.
|
This is a **dotfiles & configuration management system** combined with a rich collection of utility scripts for system administration, development workflows, and daily convenience tasks.
|
||||||
- `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 (see below).
|
|
||||||
|
|
||||||
## Key Helpers (`functions.sh`)
|
## Quick Start
|
||||||
|
|
||||||
- `can_run <cmd>` — check if command is available
|
### Installation
|
||||||
- `is_slow_init` / `is_fast_init` — check `LWS_FAST` mode
|
|
||||||
- `is_interactive_shell` — true when `[[ $- == *i* ]]`
|
|
||||||
- `is_wsl` — detect WSL environment
|
|
||||||
- `true_false <val>` — normalize `1/true/yes` to boolean
|
|
||||||
- `prepend_path` / `append_path` / `prepend_path_try` / `append_path_try` — safe PATH manipulation
|
|
||||||
- `source_try <file>` — source file if it exists
|
|
||||||
- `source_directory_sh <dir>` — source all `*.sh` in a directory
|
|
||||||
- `xlog <msg>` — debug log (only in interactive + `LWS_DEBUG`)
|
|
||||||
|
|
||||||
## Conventions
|
|
||||||
|
|
||||||
All new bash scripts should use:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#!/usr/bin/env bash
|
# Clone the repository
|
||||||
|
git clone <repository-url> ~/linux-workspace
|
||||||
|
|
||||||
set -E -o errexit -o nounset -o pipefail
|
# Run the installer
|
||||||
|
cd ~/linux-workspace
|
||||||
|
./install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
Before writing shell code, check `functions.sh` for existing helper functions and prefer them over raw commands.
|
The installer automatically:
|
||||||
|
|
||||||
RC files MUST guard slow tools and check availability:
|
- Detects the workspace directory location
|
||||||
|
- Adds sourcing configuration to `~/.bashrc`
|
||||||
|
- Creates Fish shell configuration at `~/.config/fish/conf.d/lws.fish`
|
||||||
|
|
||||||
|
### Manual Installation
|
||||||
|
|
||||||
|
Add to your `~/.bashrc`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
if is_slow_init && can_run pyenv; then
|
source /path/to/linux-workspace/bashrc
|
||||||
# initialize pyenv
|
|
||||||
fi
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Installers (`install/*.sh`) MUST be idempotent — check before installing.
|
## Project Structure
|
||||||
|
|
||||||
|
### Root Files
|
||||||
|
|
||||||
|
- [bashrc](bashrc) - Main bootstrap file that initializes the entire workspace
|
||||||
|
- [fishrc](fishrc) - Fish shell configuration entry point
|
||||||
|
- [functions.sh](functions.sh) - Core utility functions used throughout the system
|
||||||
|
- [install.sh](install.sh) - Installation script for automated setup
|
||||||
|
- [.editorconfig](.editorconfig) - EditorConfig formatting standards
|
||||||
|
|
||||||
|
### Key Directories
|
||||||
|
|
||||||
|
#### [bin/](bin/) - Utility Scripts & Tools (45+ scripts)
|
||||||
|
|
||||||
|
Collection of executable shell and Python scripts for various tasks:
|
||||||
|
|
||||||
|
**Docker & Containers:**
|
||||||
|
|
||||||
|
- [dcm](bin/dcm) - Advanced Docker Compose manager with dependency and health check features
|
||||||
|
- [docker-bridge](bin/docker-bridge), [docker-noroot](bin/docker-noroot) - Docker helpers
|
||||||
|
|
||||||
|
**Development Tools:**
|
||||||
|
|
||||||
|
- [gws](bin/gws) - Gradle wrapper shortcuts for Kotlin development
|
||||||
|
- [git-dif1](bin/git-dif1), [git-swl](bin/git-swl), [git-reset-master](bin/git-reset-master) - Git workflow utilities
|
||||||
|
|
||||||
|
**System Utilities:**
|
||||||
|
|
||||||
|
- [network-bandwidth](bin/network-bandwidth), [myip](bin/myip), [weather](bin/weather) - System info
|
||||||
|
- [lock-screen](bin/lock-screen), [suspend.sh](bin/suspend.sh), [battery](bin/battery) - System control
|
||||||
|
- [cs.sh](bin/cs.sh), [cheatsheet](bin/cheatsheet) - Cheatsheet lookup tools
|
||||||
|
|
||||||
|
**Cloud & Infrastructure:**
|
||||||
|
|
||||||
|
- [aws-login](bin/aws-login) - AWS authentication helper
|
||||||
|
- [vpn-home.sh](bin/vpn-home.sh) - VPN configuration
|
||||||
|
|
||||||
|
**Remote Tools:**
|
||||||
|
|
||||||
|
- [xmosh](bin/xmosh), [xcat](bin/xcat), [xvim](bin/xvim) - Remote execution helpers
|
||||||
|
|
||||||
|
#### [rc/](rc/) - Shell Configuration Modules (23 files)
|
||||||
|
|
||||||
|
Modular initialization scripts loaded during shell startup:
|
||||||
|
|
||||||
|
**Core Setup:**
|
||||||
|
|
||||||
|
- [01-init.fish](rc/01-init.fish) - Fish shell initialization
|
||||||
|
- [01-path.sh](rc/01-path.sh) - PATH initialization
|
||||||
|
- [02-aliases.sh](rc/02-aliases.sh) - Common command aliases
|
||||||
|
- [env.sh](rc/env.sh) - Environment variables (PAGER, EDITOR, MANPAGER)
|
||||||
|
- [bash-prompt.sh](rc/bash-prompt.sh) - Colored bash prompt
|
||||||
|
|
||||||
|
**Language/Framework Initialization:**
|
||||||
|
|
||||||
|
- [nvm.sh](rc/nvm.sh) - Node Version Manager
|
||||||
|
- [pyenv.sh](rc/pyenv.sh) - Python environment manager
|
||||||
|
- [cargo.sh](rc/cargo.sh) - Rust Cargo
|
||||||
|
- [dotnet.sh](rc/dotnet.sh) - .NET runtime
|
||||||
|
- [sdkman.sh](rc/sdkman.sh) - SDKMAN Java/Kotlin tooling
|
||||||
|
- [linuxbrew.sh](rc/linuxbrew.sh) - Homebrew for Linux
|
||||||
|
|
||||||
|
**Development Tools:**
|
||||||
|
|
||||||
|
- [ssh-agent.sh](rc/ssh-agent.sh) - SSH agent with WSL support
|
||||||
|
- [git-prompt.sh](rc/git-prompt.sh) - Git prompt decoration
|
||||||
|
- [direnv.sh](rc/direnv.sh) - Directory environment switching
|
||||||
|
- [docker.sh](rc/docker.sh) - Docker initialization
|
||||||
|
- [kubernetes.sh](rc/kubernetes.sh) - kubectl/k8s setup
|
||||||
|
- [claude-code.sh](rc/claude-code.sh) - Claude Code integration
|
||||||
|
|
||||||
|
**Other Tools:**
|
||||||
|
|
||||||
|
- [gocryptfs.sh](rc/gocryptfs.sh) - Encrypted filesystem
|
||||||
|
- [thefuck.sh](rc/thefuck.sh) - Command correction
|
||||||
|
- [enhancd.sh](rc/enhancd.sh) - Directory navigation enhancement
|
||||||
|
|
||||||
|
#### [install/](install/) - Installation Scripts (24 files)
|
||||||
|
|
||||||
|
Automated setup scripts for various tools:
|
||||||
|
|
||||||
|
**Development:**
|
||||||
|
|
||||||
|
- [git-prompt.sh](install/git-prompt.sh), [awscli.sh](install/awscli.sh)
|
||||||
|
- [docker-ce.sh](install/docker-ce.sh), [docker-compose-2.sh](install/docker-compose-2.sh)
|
||||||
|
- [go-tools.sh](install/go-tools.sh), [rust.sh](install/rust.sh)
|
||||||
|
- [npm.sh](install/npm.sh), [uv.sh](install/uv.sh)
|
||||||
|
|
||||||
|
**Services:**
|
||||||
|
|
||||||
|
- [k3s.sh](install/k3s.sh) - Lightweight Kubernetes
|
||||||
|
- [lazygit.sh](install/lazygit.sh) - Git UI
|
||||||
|
- [syncthing.sh](install/syncthing.sh) - File synchronization
|
||||||
|
|
||||||
|
**Applications:**
|
||||||
|
|
||||||
|
- [packages.sh](install/packages.sh) - Debian packages
|
||||||
|
- [sublime.sh](install/sublime.sh), [vivaldi.sh](install/vivaldi.sh)
|
||||||
|
- [pwsh.sh](install/pwsh.sh) - PowerShell
|
||||||
|
|
||||||
|
#### [scripts/](scripts/) - Helper Scripts (16 files)
|
||||||
|
|
||||||
|
Administrative and one-off scripts:
|
||||||
|
|
||||||
|
- [git-config.sh](scripts/git-config.sh) - Git user/email configuration
|
||||||
|
- [bash-template.sh](scripts/bash-template.sh) - Script template
|
||||||
|
- [gnome-configuration.sh](scripts/gnome-configuration.sh) - GNOME settings automation
|
||||||
|
- [gradle-init-kotlin.sh](scripts/gradle-init-kotlin.sh) - Gradle Kotlin project setup
|
||||||
|
- [update-desktop-apps.sh](scripts/update-desktop-apps.sh) - Application updates
|
||||||
|
|
||||||
|
#### [doc/](doc/) - Documentation (21 files)
|
||||||
|
|
||||||
|
Reference guides and cheatsheets:
|
||||||
|
|
||||||
|
- [bash.md](doc/bash.md) - Bash scripting guide
|
||||||
|
- [git.md](doc/git.md) - Git workflows
|
||||||
|
- [vim.md](doc/vim.md) - Vim editor tips
|
||||||
|
- [cheatsheet.md](doc/cheatsheet.md) - General commands
|
||||||
|
- [fzf.md](doc/fzf.md) - Fuzzy finder
|
||||||
|
- [kotlin-coding-guideline.md](doc/kotlin-coding-guideline.md) - Kotlin style guide
|
||||||
|
- [gnome.md](doc/gnome.md) - GNOME customization
|
||||||
|
|
||||||
|
#### [conf/](conf/) - Configuration Files
|
||||||
|
|
||||||
|
- [gnome-shortcuts.conf](conf/gnome-shortcuts.conf) - Keyboard shortcuts
|
||||||
|
- [gradle.properties](conf/gradle.properties) - Gradle build config
|
||||||
|
- [wsl.conf](conf/wsl.conf) - WSL settings
|
||||||
|
- [wg-home.conf](conf/wg-home.conf) - WireGuard VPN
|
||||||
|
- [packages.txt](conf/packages.txt) - Recommended Debian packages
|
||||||
|
- [applications/](conf/applications/) - Application configs
|
||||||
|
- [dircolors/](conf/dircolors/) - Directory coloring schemes
|
||||||
|
- [vim/](conf/vim/) - Vim configurations
|
||||||
|
|
||||||
|
#### [src/](src/) - Source Projects
|
||||||
|
|
||||||
|
- [battery/](src/battery/) - Python project for reading notebook battery information
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
|
||||||
|
### Bootstrap System
|
||||||
|
|
||||||
|
- **Single-entry point**: [bashrc](bashrc) sources [functions.sh](functions.sh) and loads all `.sh` files from `rc/`
|
||||||
|
- **Modular design**: Each tool has its own configuration file
|
||||||
|
- **Performance optimization**: `LWS_FAST=1` environment variable for fast initialization
|
||||||
|
- **Debug mode**: `LWS_DEBUG=1` for troubleshooting
|
||||||
|
- **Reloadable**: `reload-workspace` alias to refresh configuration
|
||||||
|
|
||||||
|
### Core Functions
|
||||||
|
|
||||||
|
The [functions.sh](functions.sh) file provides essential utilities:
|
||||||
|
|
||||||
|
- `append_path()`, `prepend_path()` - PATH manipulation with duplicate prevention
|
||||||
|
- `source_directory()`, `source_directory_sh()` - Smart recursive sourcing
|
||||||
|
- `is_fast_init()`, `is_slow_init()` - Performance-based initialization
|
||||||
|
- `can_run()`, `is_alias()` - Command availability checks
|
||||||
|
- `is_wsl()` - Windows Subsystem for Linux detection
|
||||||
|
- `xlog()` - Conditional debug logging
|
||||||
|
|
||||||
|
### Common Aliases
|
||||||
|
|
||||||
|
Defined in [rc/02-aliases.sh](rc/02-aliases.sh):
|
||||||
|
|
||||||
|
- Directory: `ll`, `la` (enhanced listing)
|
||||||
|
- Docker: `dc` (docker-compose), `dcl` (logs)
|
||||||
|
- Navigation: `..`, `...`, `....`, `cdd` (Downloads)
|
||||||
|
- Time: `now`, `nowsql`, `sqldate`
|
||||||
|
- Kubernetes: `kl`, `kld`, `klg`
|
||||||
|
- System: `ssha` (ssh-agent)
|
||||||
|
|
||||||
|
### SSH Agent Integration
|
||||||
|
|
||||||
|
The [rc/ssh-agent.sh](rc/ssh-agent.sh) module provides:
|
||||||
|
|
||||||
|
- **WSL-aware**: Special handling for Windows Subsystem for Linux
|
||||||
|
- **Multi-key support**: Checks for both id_ecdsa and id_rsa
|
||||||
|
- **Auto-start**: Automatically starts ssh-agent if not running
|
||||||
|
- **Keychain fallback**: Uses keychain for non-WSL systems
|
||||||
|
|
||||||
|
### Docker Integration
|
||||||
|
|
||||||
|
The [bin/dcm](bin/dcm) script offers advanced Docker Compose management:
|
||||||
|
|
||||||
|
- Service dependency tracking
|
||||||
|
- Health check polling (HTTP, TCP, Redis, etc.)
|
||||||
|
- Parallel builds
|
||||||
|
- Logging filtering
|
||||||
|
- Service startup orchestration
|
||||||
|
|
||||||
|
### Gradle Integration
|
||||||
|
|
||||||
|
The [bin/gws](bin/gws) tool provides shortcuts for common Gradle tasks:
|
||||||
|
|
||||||
|
- Build shortcuts: `c` (clean), `b` (build), `t` (test)
|
||||||
|
- Combined: `cb` (clean+build), `cbt` (clean+build+test)
|
||||||
|
- Skip options: `-nd` (no detekt), `-nt` (no tests)
|
||||||
|
- Java-specific: `jar` (shadowJar), `br` (bootRun)
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
- `LWS_FAST=1` — skips slow tools during shell init
|
### Core Variables
|
||||||
- `LWS_DEBUG=1` — enables debug logging via `xlog`
|
|
||||||
|
|
||||||
## Commits
|
- `$LWS` - Root directory of Linux Workspace
|
||||||
|
- `$WORKSPACE` - Alias for LWS
|
||||||
|
|
||||||
Do not add `Co-Authored-By` lines to commit messages.
|
### Configuration Flags
|
||||||
|
|
||||||
|
- `LWS_DEBUG=1` - Enable debug logging
|
||||||
|
- `LWS_FAST=1` - Fast initialization (skip slow tools)
|
||||||
|
|
||||||
|
### Tool Customization
|
||||||
|
|
||||||
|
- `DC`, `DCF` - Docker Compose customization
|
||||||
|
- `EDITOR` - Default text editor
|
||||||
|
- `PAGER` - Default pager (less)
|
||||||
|
|
||||||
|
## Important Commands
|
||||||
|
|
||||||
|
- `reload-workspace` - Reload all configurations
|
||||||
|
- `clws` - Change directory to workspace
|
||||||
|
- `dcm` - Docker Compose manager
|
||||||
|
- `gws` - Gradle wrapper shortcuts
|
||||||
|
|
||||||
|
## Configuration Strategy
|
||||||
|
|
||||||
|
The project uses an **environment-first** approach:
|
||||||
|
|
||||||
|
1. **Staged initialization**: Tools load based on `LWS_FAST` flag
|
||||||
|
2. **Conditional loading**: Tools only initialize if directories exist
|
||||||
|
3. **WSL detection**: Special paths and behaviors for Windows Subsystem for Linux
|
||||||
|
4. **Path deduplication**: Removes duplicate PATH entries
|
||||||
|
5. **EditorConfig standardization**: Consistent coding standards
|
||||||
|
|
||||||
|
## Use Cases
|
||||||
|
|
||||||
|
1. **Rapid environment setup** for new Linux machines
|
||||||
|
2. **Consistent shell configuration** across multiple systems
|
||||||
|
3. **Development tool management** (Node, Python, Rust, Go, Java)
|
||||||
|
4. **Docker/Kubernetes workflows** with helper utilities
|
||||||
|
5. **Git workflow automation**
|
||||||
|
6. **System administration** utilities and scripts
|
||||||
|
7. **Personal workspace customization** with modular components
|
||||||
|
|
||||||
|
## Customization
|
||||||
|
|
||||||
|
### Adding New Modules
|
||||||
|
|
||||||
|
1. Create a new `.sh` file in [rc/](rc/)
|
||||||
|
2. Add your configuration or aliases
|
||||||
|
3. Reload with `reload-workspace`
|
||||||
|
|
||||||
|
### Adding New Scripts
|
||||||
|
|
||||||
|
1. Create executable script in [bin/](bin/)
|
||||||
|
2. Make it executable: `chmod +x bin/yourscript`
|
||||||
|
3. Script is automatically available in PATH
|
||||||
|
|
||||||
|
### Disabling Modules
|
||||||
|
|
||||||
|
Move unwanted modules from [rc/](rc/) to [rc.available/](rc.available/)
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
The workspace intelligently detects and initializes available tools:
|
||||||
|
|
||||||
|
- **Required**: bash, git
|
||||||
|
- **Optional**: docker, kubectl, nvm, pyenv, cargo, direnv, etc.
|
||||||
|
- **Detection**: Each module checks for tool availability before initialization
|
||||||
|
|
||||||
|
## WSL Support
|
||||||
|
|
||||||
|
Special handling for Windows Subsystem for Linux:
|
||||||
|
|
||||||
|
- SSH agent integration with Windows
|
||||||
|
- Path adjustments for Windows interoperability
|
||||||
|
- WSL-specific configurations in [conf/wsl.conf](conf/wsl.conf)
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
- **Fast mode**: Set `LWS_FAST=1` to skip heavy initializations
|
||||||
|
- **Lazy loading**: Tools only load when directories exist
|
||||||
|
- **Optimized PATH**: Deduplication prevents PATH bloat
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
This is a personal workspace configuration, but improvements are welcome:
|
||||||
|
|
||||||
|
1. Follow existing naming conventions
|
||||||
|
2. Keep scripts modular and self-contained
|
||||||
|
3. Test on fresh installations
|
||||||
|
4. Document new features in appropriate [doc/](doc/) files
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Personal project - use and modify as needed for your own workspace.
|
||||||
|
|
||||||
|
## Recent Changes
|
||||||
|
|
||||||
|
- Installation script improvements
|
||||||
|
- Enhanced `ll` and `la` aliases
|
||||||
|
- SSH agent fixes for WSL
|
||||||
|
- Fish shell integration
|
||||||
|
- Addition of new tools (Claude Code, Gemini CLI)
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
For issues or questions, refer to the documentation in [doc/](doc/) or examine the relevant configuration files in [rc/](rc/).
|
||||||
|
|||||||
7
bashrc
7
bashrc
@@ -7,16 +7,13 @@ export LWS=$WORKSPACE
|
|||||||
LWS_DEBUG=${LWS_DEBUG:-0}
|
LWS_DEBUG=${LWS_DEBUG:-0}
|
||||||
LWS_FAST=${LWS_FAST:-0}
|
LWS_FAST=${LWS_FAST:-0}
|
||||||
|
|
||||||
source "$LWS/functions.sh"
|
echo "Linux Workspace initialization"
|
||||||
|
|
||||||
if [[ -z $LC_ALL ]]; then
|
if [[ -z $LC_ALL ]]; then
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_interactive_shell; then
|
source "$LWS/functions.sh"
|
||||||
echo "Linux Workspace initialization"
|
|
||||||
fi
|
|
||||||
|
|
||||||
source_directory_sh "$LWS/rc"
|
source_directory_sh "$LWS/rc"
|
||||||
source_directory_sh "$HOME/.bashrc.d"
|
source_directory_sh "$HOME/.bashrc.d"
|
||||||
|
|
||||||
|
|||||||
75
bin/xclaude
75
bin/xclaude
@@ -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)
|
|
||||||
14
fishrc
14
fishrc
@@ -1,3 +1,11 @@
|
|||||||
for file in (dirname (status -f))/rc.fish/*.fish
|
# ~/.config/fish/config.fish
|
||||||
source $file
|
# echo "source $LWS/fishrc" > $__fish_config_dir/conf.d/lws.fish
|
||||||
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"
|
||||||
|
|||||||
11
functions.sh
11
functions.sh
@@ -1,14 +1,9 @@
|
|||||||
# 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'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function is_interactive_shell() {
|
|
||||||
[[ $- == *i* ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_fast_init() {
|
function is_fast_init() {
|
||||||
(( $LWS_FAST ))
|
(( $LWS_FAST ))
|
||||||
}
|
}
|
||||||
@@ -18,7 +13,7 @@ function is_slow_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function xlog() {
|
function xlog() {
|
||||||
if is_interactive_shell && true_false "$LWS_DEBUG"; then
|
if true_false "$LWS_DEBUG"; then
|
||||||
echo "$@"
|
echo "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -104,11 +99,11 @@ function source_directory() {
|
|||||||
xlog "LOAD DIR $mask"
|
xlog "LOAD DIR $mask"
|
||||||
for file in $mask; do
|
for file in $mask; do
|
||||||
if [[ -e "$file" ]]; then
|
if [[ -e "$file" ]]; then
|
||||||
if is_interactive_shell && (( $LWS_DEBUG )); then
|
if (( $LWS_DEBUG )); then
|
||||||
start=$($time_ms)
|
start=$($time_ms)
|
||||||
source "$file"
|
source "$file"
|
||||||
stop=$($time_ms)
|
stop=$($time_ms)
|
||||||
xlog "LOAD FILE $file $((stop - start)) ms"
|
echo "LOAD FILE $file $((stop - start)) ms"
|
||||||
else
|
else
|
||||||
source "$file"
|
source "$file"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -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
|
|
||||||
|
|
||||||
@@ -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"
|
|
||||||
0
rc/01-init.fish
Normal file
0
rc/01-init.fish
Normal file
@@ -15,7 +15,6 @@ 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'"
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# Terminal colors
|
|
||||||
LWS_RED=$(tput setaf 1)
|
|
||||||
LWS_GREEN=$(tput setaf 2)
|
|
||||||
LWS_CYAN=$(tput setaf 6)
|
|
||||||
LWS_COLOR_RESET=$(tput sgr0)
|
|
||||||
|
|
||||||
# Bash prompt escape sequences
|
|
||||||
LWS_PS1_USER='\u'
|
|
||||||
LWS_PS1_HOST='\h'
|
|
||||||
LWS_PS1_DIR='\w'
|
|
||||||
LWS_PS1_TYPE='\$'
|
|
||||||
LWS_PS1_USER_HOST="${LWS_GREEN}${LWS_PS1_USER}@${LWS_PS1_HOST}${LWS_COLOR_RESET}:${LWS_CYAN}${LWS_PS1_DIR}${LWS_COLOR_RESET}"
|
|
||||||
@@ -2,9 +2,19 @@
|
|||||||
# https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
|
# https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
|
||||||
# https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
|
# https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
|
||||||
|
|
||||||
|
RED=$(tput setaf 1)
|
||||||
|
GREEN=$(tput setaf 2)
|
||||||
|
CYAN=$(tput setaf 6)
|
||||||
|
COLOR_RESET=$(tput sgr0)
|
||||||
|
|
||||||
function get_ps1_prompt()
|
function get_ps1_prompt()
|
||||||
{
|
{
|
||||||
echo "${debian_chroot:+($debian_chroot)}${LWS_PS1_USER_HOST}${LWS_PS1_TYPE} "
|
local username='\u'
|
||||||
|
local hostname='\h'
|
||||||
|
local workdir='\w'
|
||||||
|
local user_type='\$'
|
||||||
|
|
||||||
|
echo "${debian_chroot:+($debian_chroot)}${GREEN}${username}@${hostname}${COLOR_RESET}:${CYAN}${workdir}${COLOR_RESET}${user_type} "
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_ps1_prompt()
|
function set_ps1_prompt()
|
||||||
|
|||||||
@@ -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 can_run dircolors && [[ -f "$COLORS_FILE" ]]; then
|
if [[ -f "$COLORS_FILE" ]]; then
|
||||||
xlog "Loading colors $COLORS_FILE"
|
xlog "Loading colors $COLORS_FILE"
|
||||||
eval "$(dircolors "$COLORS_FILE")"
|
eval "$(dircolors "$COLORS_FILE")"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -9,8 +9,5 @@ GIT_PROMPT_INIT="$GIT_PROMPT_PATH/gitprompt.sh"
|
|||||||
if [ -f "$GIT_PROMPT_INIT" ]; then
|
if [ -f "$GIT_PROMPT_INIT" ]; then
|
||||||
export GIT_PROMPT_PATH
|
export GIT_PROMPT_PATH
|
||||||
GIT_PROMPT_ONLY_IN_REPO=1
|
GIT_PROMPT_ONLY_IN_REPO=1
|
||||||
GIT_PROMPT_USER_HOST="${LWS_PS1_USER_HOST}"
|
|
||||||
GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_USER_HOST}"
|
|
||||||
GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}"
|
|
||||||
source "$GIT_PROMPT_INIT"
|
source "$GIT_PROMPT_INIT"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
append_path_try "$HOME/.opencode/bin"
|
|
||||||
Reference in New Issue
Block a user