-
Notifications
You must be signed in to change notification settings - Fork 1
feat: zsh: Add Hotkey Insertions hack #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1c08214 to
0e26341
Compare
Configure hotkeys to insert specific text into your command buffer, including cursor placement, which is highly useful for boilerplate commands. Features: - Use bindkey -s to map key sequences to text insertion - Control cursor placement with special characters (^B, ^F, etc.) - Auto-execute commands with ^M (Enter) - Reduce typing for frequently used commands Included hotkey shortcuts: - Git commands (commit, add, push, status, diff, log) - Docker commands (compose, ps, exec) - Common patterns (ls -lah, cd .., mkdir -p) - Search patterns (find, rg) Examples: bindkey -s '^Xgc' 'git commit -m ""^B' # Ctrl+X g c inserts: git commit -m "" # with cursor between quotes (^B moves back) bindkey -s '^Xgs' 'git status^M' # Ctrl+X g s runs git status immediately Reference: https://www.youtube.com/watch?v=3fVAtaGhUyU (15:19-16:50)
0e26341 to
452b7d6
Compare
Code Review: Zsh Hotkey Insertions FeatureSummaryThis PR adds excellent productivity features for Zsh, including hotkey insertions, command-line editing enhancements, and several quality-of-life improvements. The code is well-documented and follows the established patterns in the repository. ✅ Strengths1. Excellent Documentation
2. Code Quality
3. User Experience
🔍 Issues & Recommendations1. Potential Conflict with Atuin (Medium Priority)File: bindkey ' ' magic-spaceIssue: Your Impact: Users might not get the expected magic-space behavior, or Atuin features might break. Recommendation: # Check if magic-space is compatible with your current setup
# If using Atuin, this binding may be overridden
# Consider testing: type "!!" then press space to verify expansion works
bindkey ' ' magic-spaceOr move this file to load AFTER 2. Keybinding Conflicts (Medium Priority)File: Issue: Several Ctrl+X combinations might conflict with existing bindings:
Recommendation: Add a conflict check section at the top: # Check for existing keybinding conflicts
# Run: bindkey | grep '\^X' to see current Ctrl+X bindings
# Uncomment to see what's currently bound:
# bindkey | grep '\^X'3. Cursor Movement in Docker Example (Low Priority)File: bindkey -s '^Xde' 'docker exec -it /bin/bash^B^B^B^B^B^B^B^B^B^B'Issue: This uses 10 Alternative approach: Use cursor positioning that's more maintainable: bindkey -s '^Xde' 'docker exec -it ^A^F^F^F^F^F^F^F^F^F^F^F^F^F^F^F' # Position after "docker exec -it "Or consider using a ZLE widget instead for more complex cursor positioning: docker-exec-widget() {
LBUFFER='docker exec -it '
RBUFFER=' /bin/bash'
}
zle -N docker-exec-widget
bindkey '^Xde' docker-exec-widgetThis is more maintainable and clearer in intent. 4. Missing Error Handling (Low Priority)File: autoload -Uz edit-command-lineIssue: No verification that autoload succeeded. If Recommendation: # Load the edit-command-line widget
if autoload -Uz edit-command-line 2>/dev/null; then
zle -N edit-command-line
bindkey '^X^E' edit-command-line
else
print "Warning: edit-command-line widget not available" >&2
fi5. Ordering Consideration (Low Priority)File: The new includes are loaded in this order: source_config "inc.edit-command-line.zsh"
source_config "inc.undo.zsh"
source_config "inc.magic-space.zsh"
source_config "inc.chpwd.zsh"
source_config "inc.suffix-aliases.zsh"
source_config "inc.global-aliases.zsh"
source_config "inc.zmv.zsh"
source_config "inc.named-directories.zsh"
source_config "inc.custom-widgets.zsh"
source_config "inc.hotkey-insertions.zsh"Observation: Recommendation: Either:
6. Named Directories - No Examples (Low Priority)File: Observation: All examples are commented out. While this prevents unwanted behavior, users might not realize the feature exists without at least one working example. Recommendation: Add one safe, universal example: # Example: Quick access to dotfiles directory
hash -d dotfiles=~/.dotfiles
# Add your custom named directories below:This gives users immediate value and demonstrates the feature. 🔒 Security ConsiderationsNo security issues identified. The code:
⚡ Performance ConsiderationsExcellent performance characteristics:
🧪 Test CoverageObservation: This repository doesn't appear to have automated tests for Zsh configurations. Recommendation for future work: # Test that hotkey insertions load without errors
source zsh/inc.hotkey-insertions.zsh
# Verify bindings exist
bindkey | grep '\^Xgc'This is not required for this PR but would improve maintainability. 📋 Minor Suggestions
✅ ConclusionThis is a high-quality PR that adds valuable functionality while maintaining code quality and documentation standards. The issues identified are minor and mostly relate to potential conflicts with existing tools (Atuin) and edge cases. Recommendation: Approve with minor changes Priority fixes before merge:
Nice-to-have improvements:
Great work on the documentation and educational references! 🚀 |
PR Review: feat: zsh: Add Hotkey Insertions hackSummaryThis PR adds a new Zsh configuration file for hotkey insertions using ✅ Strengths
|
Pull Request Review: Hotkey Insertions FeatureSummaryThis PR adds a useful feature for creating shell command macros using Code Quality: ⭐⭐⭐⭐⭐Strengths:
Observations:
Potential Issues:
|
…e a ZLE function instead
… + fix conflicting ^Xd binding between date insertion and docker cmd expansions
4cbd776 to
d055534
Compare
|
Review: Hotkey Insertions Feature Summary: This PR introduces a well-designed hotkey insertion system for Zsh that allows binding key sequences to insert boilerplate commands with intelligent cursor placement. The implementation is clean, well-documented, and follows the repository conventions. STRENGTHS: Code Quality:
Design Decisions:
Integration:
ISSUES AND RECOMMENDATIONS:
Command injection risk in _insert_with_cursor (line 44-50): Docker exec defaults to /bin/bash (line 67):
Date insertion may behave differently on systems: Keybinding conflicts not documented:
Negligible performance impact - implementation is efficient:
Function naming: Using underscore prefix is correct for private/internal functions per Zsh conventions. Consider documenting this. Missing function documentation: While file header is excellent, individual widget functions lack docstrings.
No automated tests - consider adding manual test checklist:
Missing documentation about:
Consider adding troubleshooting section with commands like: bindkey | grep "^X", bindkey -r "^Xgc", zle -la | grep hotkey BEST PRACTICES: Things done well:
Suggestions:
SECURITY ASSESSMENT: Low Risk
OVERALL ASSESSMENT: APPROVE with minor suggestions This is high-quality work that:
The issues raised are mostly minor suggestions for enhancement rather than blocking problems. The code is production-ready as-is. Suggested next steps:
Great work! This is a valuable addition to the dotfiles. Review generated by Claude Code |
Summary
Configure hotkeys to insert specific text into your command buffer, including cursor placement, which is highly useful for boilerplate commands.
What it achieves
^Bmoves back,^Mexecutes)Zsh Configuration
Special characters:
^B= Move cursor back^M= Enter (auto-execute)^A/^E= Beginning/End of lineReference
Additional Applications & Inspiration