When working on large codebases, developers often need to switch between different features or areas of the application. The focus
script helps manage this cognitive load by creating organized workspaces for different contexts.
Working on features that span multiple directories (controllers, models, views, specs) requires constant navigation and context switching. This leads to keeping multiple editor windows open, maintaining mental lists of relevant files, and repeatedly searching through deep directory structures.
The focus
script creates virtual workspaces using symlinks. It maintains a configuration file where you define groups of related files and directories. When you switch to a focus area, the script creates a dedicated directory with symlinks to all relevant files, preserving their original structure while making them easily accessible in one place.
- First-time run creates an example configuration
- Opens the config file in your editor for immediate customization
- Creates directory structure as needed
- Handles both files and directories
- Maintains original file structure within the focus directory
When you update your configuration, you can refresh your focus area without losing existing symlinks:
bin/focus invoices --refresh
Define your focus areas in .focus/config.yml
:
invoices:
- app/assets/stylesheets/components.css
- app/components/invoices
- app/components/ui/picker
- app/controllers/invoices_controller.rb
- app/controllers/invoices
- app/controllers/picker
- app/models/invoice.rb
- app/models/invoice_item.rb
- app/views/invoices
- app/views/picker
# First time setup
bin/focus
# Switch to a focus area
bin/focus invoices
# Update after config changes
bin/focus invoices --refresh
- Reduced Cognitive Load: All relevant files for a feature are in one place
- Faster Navigation: No need to dig through deep directory structures
- Non-Destructive: Uses symlinks, so original files remain unchanged
- Flexible: Easy to update and modify focus areas as needed
- Copy the
focus
script to your project'sbin
directory - Make it executable:
chmod +x bin/focus
- Include both implementation and test files in your focus areas
- Use directories when you need all files in a folder
- Use
--refresh
when you want to preserve existing links
The focus
script is a simple tool that can significantly improve your development workflow by reducing the friction of context switching and keeping related files easily accessible.