diff options
author | Elizabeth <lizhunt@amazon.com> | 2025-05-28 15:39:58 -0700 |
---|---|---|
committer | Elizabeth <lizhunt@amazon.com> | 2025-05-28 15:39:58 -0700 |
commit | 1c2bd3faf3a1f0cd456a25b19ec404e1f79518c3 (patch) | |
tree | fc9dfd41e8b5769a4d178e0a9e7173a1c005f425 | |
parent | daa475736378bb3c9a9c24307cb1f37603057f32 (diff) | |
download | dotfiles-1c2bd3faf3a1f0cd456a25b19ec404e1f79518c3.tar.gz dotfiles-1c2bd3faf3a1f0cd456a25b19ec404e1f79518c3.zip |
Add smarter templating thanks to AI
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | contexts.json | 61 | ||||
-rw-r--r-- | dots.py | 190 | ||||
-rw-r--r-- | home/Pictures/wallpapers/flat-books.png (renamed from home/Pictures/wallpapers/Pages.png) | bin | 1133976 -> 1133976 bytes | |||
-rw-r--r-- | home/Pictures/wallpapers/ghibli-road.png (renamed from home/Pictures/wallpapers/5m5kLI9.png) | bin | 313297 -> 313297 bytes | |||
-rw-r--r-- | home/Pictures/wallpapers/penguins-hugging.jpg | bin | 0 -> 519955 bytes | |||
-rw-r--r-- | home/Pictures/wallpapers/rose.png (renamed from home/Pictures/wallpapers/rose01.png) | bin | 1508642 -> 1508642 bytes | |||
-rw-r--r-- | home/Pictures/wallpapers/snowy-light-trees.jpg (renamed from home/Pictures/wallpapers/maciek-sulkowski-fJ-22PLNGvE.jpg) | bin | 1283226 -> 1283226 bytes | |||
-rw-r--r-- | home/Pictures/wallpapers/sunrise-mountains.webp (renamed from home/Pictures/wallpapers/Flight1.webp) | bin | 62148 -> 62148 bytes | |||
-rwxr-xr-x | home/scripts/greet.sh | 6 | ||||
-rw-r--r-- | zed/.config/zed/keymap.json | 14 | ||||
-rw-r--r-- | zed/.config/zed/settings.json | 261 |
12 files changed, 500 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9daf20c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.compiled_dotfiles/ diff --git a/contexts.json b/contexts.json new file mode 100644 index 0000000..36788f3 --- /dev/null +++ b/contexts.json @@ -0,0 +1,61 @@ +{ + "osx": { + "work": { + "user": { + "name": "Elizabeth Hunt", + "email": "lizhunt@amazon.com", + "work_email": "lizhunt@amazon.com", + "personal_email": "me@liz.coffee" + }, + "paths": { + "homebrew": "/opt/homebrew", + "toolbox": "$HOME/.toolbox/bin" + }, + "features": { + "work_mode": true, + "gpg": true, + "amazon_tools": true + }, + "settings": { + "pinentry": "mac", + "theme": "work" + } + }, + "armin": { + "user": { + "name": "Elizabeth Alexander Hunt", + "email": "me@liz.coffee", + "personal_email": "me@liz.coffee" + }, + "paths": { + "homebrew": "/opt/homebrew" + }, + "features": { + "work_mode": false, + "gpg": true + }, + "settings": { + "pinentry": "mac", + "theme": "personal" + } + } + }, + "linux": { + "default": { + "user": { + "name": "Elizabeth Alexander Hunt", + "email": "me@liz.coffee", + "personal_email": "me@liz.coffee" + }, + "features": { + "work_mode": false, + "gpg": true, + "amazon_tools": false + }, + "settings": { + "pinentry": "qt", + "theme": "dark" + } + } + } +} @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 + +import argparse +import json +import os +import shutil +import subprocess +import sys +from pathlib import Path +import jinja2 + +def get_platform(): + """Get the platform using the platform.sh script""" + try: + script_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "home/scripts/platform.sh") + result = subprocess.run([script_path], capture_output=True, text=True, check=True) + return result.stdout.strip() + except subprocess.CalledProcessError as e: + print(f"Error getting platform: {e}") + sys.exit(1) + +def get_device_name(): + """Get the device name using the system_name.sh script""" + try: + script_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "home/scripts/system_name.sh") + result = subprocess.run([script_path], capture_output=True, text=True, check=True) + return result.stdout.strip() + except subprocess.CalledProcessError as e: + print(f"Error getting device name: {e}") + sys.exit(1) + +def load_context(platform, device_name): + """Load the appropriate context from contexts.json""" + try: + with open('contexts.json', 'r') as f: + contexts = json.load(f) + + if platform not in contexts: + print(f"Warning: Platform '{platform}' not found in contexts.json") + return {} + + if device_name not in contexts[platform]: + print(f"Warning: Device '{device_name}' not found for platform '{platform}' in contexts.json") + # Try to use 'default' for the platform if device not found + if 'default' in contexts[platform]: + print(f"Using default context for platform '{platform}'") + return contexts[platform]['default'] + return {} + + return contexts[platform][device_name] + except FileNotFoundError: + print("Warning: contexts.json not found") + return {} + except json.JSONDecodeError as e: + print(f"Error parsing contexts.json: {e}") + sys.exit(1) + +def compile_dotfiles(source_dir, target_dir, context): + """Compile dotfiles, processing Jinja templates with context""" + # Create jinja environment + env = jinja2.Environment( + undefined=jinja2.StrictUndefined, + trim_blocks=True, + lstrip_blocks=True + ) + + # Ensure target directory exists + target_path = Path(target_dir) + target_path.mkdir(exist_ok=True, parents=True) + + # Process each file in source directory + for root, dirs, files in os.walk(source_dir): + # Skip .git directories + if '.git' in dirs: + dirs.remove('.git') + + # Create relative path from source_dir + rel_path = os.path.relpath(root, source_dir) + if rel_path == '.': + rel_path = '' + + # Create target directory + if rel_path: + target_subdir = target_path / rel_path + target_subdir.mkdir(exist_ok=True, parents=True) + else: + target_subdir = target_path + + for file in files: + source_file = os.path.join(root, file) + + # Determine target filename (remove .j2 extension for templates) + target_file_name = file[:-3] if file.endswith('.j2') else file + target_file = target_subdir / target_file_name + + print(f"Processing: {source_file} -> {target_file}") + + if file.endswith('.j2'): + # Render Jinja2 template + try: + with open(source_file, 'r') as f: + template_content = f.read() + + # Use the environment to create templates + template = env.from_string(template_content) + rendered_content = template.render(**context) + + # Write rendered content to target file + with open(target_file, 'w') as f: + f.write(rendered_content) + + # Make executable if source is executable + if os.access(source_file, os.X_OK): + os.chmod(target_file, 0o755) + + except Exception as e: + print(f"Error rendering template {source_file}: {e}") + else: + # Copy file as-is + shutil.copy2(source_file, target_file) + +def stow_dotfiles(dotfiles_dir, target_dir=None): + """Use GNU Stow to symlink the compiled dotfiles""" + if target_dir is None: + target_dir = os.path.expanduser("~") + + # Check if stow is installed + try: + subprocess.run(["stow", "--version"], capture_output=True, check=True) + except (subprocess.CalledProcessError, FileNotFoundError): + print("Error: GNU Stow not found. Please install it before using --stow.") + sys.exit(1) + + # Get list of directories in dotfiles_dir (each is a stow package) + packages = [d for d in os.listdir(dotfiles_dir) if os.path.isdir(os.path.join(dotfiles_dir, d))] + + for package in packages: + print(f"Stowing package: {package}") + try: + # Use --adopt to replace existing files + # Use --no-folding to enable leaf mode (each file individually linked) + subprocess.run([ + "stow", + "--dir=" + dotfiles_dir, + "--target=" + target_dir, + "--adopt", + "--no-folding", + package + ], check=True) + print(f"Successfully stowed {package}") + except subprocess.CalledProcessError as e: + print(f"Error stowing {package}: {e}") + +def main(): + parser = argparse.ArgumentParser(description="Dotfiles manager") + parser.add_argument("--compile", action="store_true", help="Compile dotfiles") + parser.add_argument("--stow", action="store_true", help="Stow compiled dotfiles") + parser.add_argument("--target", help="Target directory for stow (default: $HOME)") + args = parser.parse_args() + + if not args.compile and not args.stow: + parser.print_help() + sys.exit(1) + + platform = get_platform() + device_name = get_device_name() + print(f"Platform: {platform}, Device: {device_name}") + + context = load_context(platform, device_name) + print(f"Loaded context: {context}") + + # Add platform and device_name to context + context['platform'] = platform + context['device_name'] = device_name + + compiled_dir = ".compiled_dotfiles" + + if args.compile: + print(f"Compiling dotfiles from 'dotfiles' to '{compiled_dir}'...") + compile_dotfiles("dotfiles", compiled_dir, context) + print("Compilation complete.") + + if args.stow: + target_dir = args.target if args.target else None + print(f"Stowing dotfiles from '{compiled_dir}'...") + stow_dotfiles(compiled_dir, target_dir) + print("Stowing complete.") + +if __name__ == "__main__": + main() diff --git a/home/Pictures/wallpapers/Pages.png b/home/Pictures/wallpapers/flat-books.png Binary files differindex 3e4cf16..3e4cf16 100644 --- a/home/Pictures/wallpapers/Pages.png +++ b/home/Pictures/wallpapers/flat-books.png diff --git a/home/Pictures/wallpapers/5m5kLI9.png b/home/Pictures/wallpapers/ghibli-road.png Binary files differindex bf7b60d..bf7b60d 100644 --- a/home/Pictures/wallpapers/5m5kLI9.png +++ b/home/Pictures/wallpapers/ghibli-road.png diff --git a/home/Pictures/wallpapers/penguins-hugging.jpg b/home/Pictures/wallpapers/penguins-hugging.jpg Binary files differnew file mode 100644 index 0000000..ee21cc5 --- /dev/null +++ b/home/Pictures/wallpapers/penguins-hugging.jpg diff --git a/home/Pictures/wallpapers/rose01.png b/home/Pictures/wallpapers/rose.png Binary files differindex 0b11bcb..0b11bcb 100644 --- a/home/Pictures/wallpapers/rose01.png +++ b/home/Pictures/wallpapers/rose.png diff --git a/home/Pictures/wallpapers/maciek-sulkowski-fJ-22PLNGvE.jpg b/home/Pictures/wallpapers/snowy-light-trees.jpg Binary files differindex c2f6350..c2f6350 100644 --- a/home/Pictures/wallpapers/maciek-sulkowski-fJ-22PLNGvE.jpg +++ b/home/Pictures/wallpapers/snowy-light-trees.jpg diff --git a/home/Pictures/wallpapers/Flight1.webp b/home/Pictures/wallpapers/sunrise-mountains.webp Binary files differindex c59bd58..c59bd58 100644 --- a/home/Pictures/wallpapers/Flight1.webp +++ b/home/Pictures/wallpapers/sunrise-mountains.webp diff --git a/home/scripts/greet.sh b/home/scripts/greet.sh index 00b6be5..cb2aae5 100755 --- a/home/scripts/greet.sh +++ b/home/scripts/greet.sh @@ -4,12 +4,12 @@ source log.sh "greet.sh" pick_greeting() { path="$1" greetings=("$1"/*) - greeting="${greetings[$RANDOM % ${#greetings[@]}]}" - echo "$greeting" + greeting_path="${greetings[$RANDOM % ${#greetings[@]}]}" + echo "$greeting_path" } GREETINGS_LIST="$XDG_CONFIG_HOME/zsh/greetings" -if [ ! -d "$GREETINGS_LIST" ]; then +if [ ! -d "$GREETINGS_LIST" ]; then log DEBUG "no such file $GREETINGS_LIST" exit 0 fi diff --git a/zed/.config/zed/keymap.json b/zed/.config/zed/keymap.json new file mode 100644 index 0000000..816b7c6 --- /dev/null +++ b/zed/.config/zed/keymap.json @@ -0,0 +1,14 @@ +[ + { + "context": "Workspace", + "bindings": { + "shift shift": "file_finder::Toggle" + } + }, + { + "context": "Editor", + "bindings": { + // "j k": ["workspace::SendKeystrokes", "escape"] + } + } +] diff --git a/zed/.config/zed/settings.json b/zed/.config/zed/settings.json index cfe45d7..69f987f 100644 --- a/zed/.config/zed/settings.json +++ b/zed/.config/zed/settings.json @@ -1,29 +1,68 @@ { - "project_panel": { - "dock": "right" - }, - "agent": { - "dock": "left", - "version": "1" - }, + // -- <telemetry> -- "telemetry": { "metrics": false, "diagnostics": false }, + "features": { + "copilot": false + }, + "show_copilot_suggestions": false, + // -- </telemetry> -- + + // -- <keys> -- "vim_mode": true, "base_keymap": "JetBrains", + // -- </keys> -- + + // -- <text> -- "ui_font_size": 14, "tab_size": 4, "buffer_font_size": 14, "ui_font_family": "Agave Nerd Font Mono", "buffer_font_family": "Agave Nerd Font Mono", + // -- </text> -- + + // -- <theme> -- "theme": { "mode": "system", "light": "Gruvbox Light Hard", "dark": "Gruvbox Dark Soft" }, - "format_on_save": "off", + // -- </theme> -- + + // -- <line_view> -- "relative_line_numbers": true, + "current_line_highlight": "all", + "show_whitespaces": "selection", + // -- </line_view> -- + + // -- <on_save> -- + "format_on_save": "off", + "ensure_final_newline_on_save": true, + // -- </on_save> -- + + // -- <layout> -- + "centered_layout": { + "left_padding": 0.1, + "right_padding": 0.1 + }, + "tab_bar": { + "show": false + }, + "toolbar": { + "breadcrumbs": false, + "quick_actions": false, + "selections_menu": false, + "agent_review": false, + "code_actions": false + }, + "project_panel": { + "dock": "right" + }, + // -- </layout> -- + + // -- <languages> -- "lsp": { "jdtls": { "initialization_options": { @@ -40,38 +79,200 @@ } } } - }, - "deno": { - "settings": { - "deno": { - "enable": true - } - } } }, "languages": { "Java": { - "formatter": "language_server", + "formatter": "prettier", "format_on_save": "off", "language_servers": ["jdtls"] }, "TypeScript": { - "language_servers": [ - //"deno", - "typescript-language-server", - "!vtsls", - "!eslint" - ], - "formatter": "language_server" + "language_servers": ["typescript-language-server"], + "formatter": "prettier" }, "TSX": { - "language_servers": [ - "deno", - "!typescript-language-server", - "!vtsls", - "!eslint" - ], - "formatter": "language_server" + "language_servers": ["typescript-language-server"], + "formatter": "prettier" + } + }, + // -- </languages> -- + + // -- <extensions> -- + "auto_install_extensions": { + "html": true, + "dockerfile": true, + "docker-compose": true, + "ansible": true, + "deno": true, + "java": true, + "kotlin": true, + "toml": true, + + // https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking + "mcp-server-sequential-thinking": true + }, + // -- </extensions> -- + + // -- <amzn_ai> -- + "language_models": { + "bedrock": { + "authentication_method": "named_profile", + "profile": "cline", + "region": "us-west-2" } + }, + "context_servers": { + // wasabi's MCP server + "wasabi": { + "command": { + "path": "wasabi", + "args": ["--mcp-server"], + "env": null + }, + "settings": {} + }, + // the internal general MCP server + "Amazon Internal MCP": { + "command": { + "path": "amzn_ai-mcp", + "args": [], + "env": null + }, + "settings": {} + }, + // offical AWS Docs MCP server built by Labs + "AWS Documentation MCP Server": { + "command": { + "path": "mise", + "args": [ + "exec", + "uv@latest", + "--", + "uvx", + "awslabs.aws-documentation-mcp-server@latest" + ], + "env": { + "FASTMCP_LOG_LEVEL": "ERROR" + } + } + } + }, + "agent": { + "dock": "left", + "profiles": { + "starter-profile": { + "name": "Starter Profile", + "tools": { + "copy_path": false, + "create_directory": false, + "delete_path": false, + "diagnostics": false, + "edit_file": true, + "fetch": false, + "find_path": false, + "grep": false, + "list_directory": true, + "move_path": false, + "terminal": false, + "read_file": true, + "open": true, + "now": true, + "thinking": true + }, + "context_servers": { + "wasabi": { + "tools": { + "WorkspaceSearch": true, + "ReadInternalWebsites": true, + "Delegate": true + } + }, + "mcp-server-sequential-thinking": { + "tools": { + "sequentialthinking": true + } + }, + "Amazon Internal MCP": { + "tools": { + "write_internal_website": true, + "tod_download_logs": true, + "taskei_get_task": true, + "slack-send-message": true, + "sim_update_issue": true, + "sim_search_issues": true, + "sim_get_issue": true, + "sim_get_folders": true, + "sim_create_issue": true, + "sim_add_tag": true, + "sim_add_comment": true, + "search_symphony": true, + "search_sable": true, + "search_products": true, + "search_quip": true, + "search_people": true, + "search_katal_components": true, + "search_internal_websites": true, + "search_internal_issues": true, + "search_datapath": true, + "search_internal_code": true, + "read_quip": true, + "read_orr": true, + "read_kingpin_goal": true, + "read_internal_website": true, + "read_coe": true, + "prompt_farm_search_prompts": true, + "prompt_farm_prompt_content": true, + "policy_engine_get_user_dashboard": true, + "policy_engine_get_risk": true, + "plantuml": true, + "pippin_update_project": true, + "pippin_update_artifact": true, + "pippin_list_projects": true, + "pippin_list_artifacts": true, + "pippin_get_project": true, + "pippin_get_artifact": true, + "pippin_create_project": true, + "pippin_create_artifact": true, + "mox_console": true, + "lookup_user_coding_activity_summary": true, + "lookup_team_code_resource": true, + "list_katal_components": true, + "get_recent_messages_quip": true, + "get_katal_component": true, + "edit_quip": true, + "create_quip": true + } + }, + "AWS Documentation MCP Server": { + "tools": { + "recommend": true, + "search_documentation": true, + "read_documentation": true + } + } + } + } + }, + "default_profile": "starter-profile", + "inline_assistant_model": { + "provider": "amazon-bedrock", + "model": "amazon.nova-lite-v1:0" + }, + "commit_message_model": { + "provider": "amazon-bedrock", + "model": "amazon.nova-lite-v1:0" + }, + "thread_summary_model": { + "provider": "amazon-bedrock", + "model": "amazon.nova-lite-v1:0" + }, + "always_allow_tool_actions": true, + "default_model": { + "provider": "amazon-bedrock", + "model": "anthropic.claude-3-7-sonnet-20250219-v1:0" + }, + "version": "2" } + // -- </amzn_ai> -- } |