-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtreehouse.plugin.zsh
More file actions
76 lines (66 loc) · 2.69 KB
/
treehouse.plugin.zsh
File metadata and controls
76 lines (66 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# ============================================================================
# treehouse.plugin.zsh - Modular Autoload Loader
# ============================================================================
# Git worktrees management for Zsh
#
# This is the minimal loader that autoloads all commands on-demand for
# fast startup and clean organization.
#
# Installation:
# 1. Clone into Oh My Zsh custom plugins:
# git clone https://github.com/linnjs/treehouse ~/.oh-my-zsh/custom/plugins/treehouse
# 2. Add 'treehouse' to plugins array in ~/.zshrc:
# plugins=(... treehouse)
# 3. Reload shell: source ~/.zshrc
# 4. Run 'gwt help' for usage
#
# ============================================================================
# Double-load prevention
if [[ -n "$TREEHOUSE_PLUGIN_LOADED" ]]; then
return 0
fi
TREEHOUSE_PLUGIN_LOADED=1
# Get absolute path to plugin directory
# Use ${0:A:h} for compatibility with all plugin managers
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
0="${${(M)0:#/*}:-$PWD/$0}"
export TREEHOUSE_PLUGIN_DIR="${0:A:h}"
# Source configuration and color support
source "$TREEHOUSE_PLUGIN_DIR/lib/config.zsh"
source "$TREEHOUSE_PLUGIN_DIR/lib/colors.zsh"
# Add functions directories to fpath for autoloading
fpath=("$TREEHOUSE_PLUGIN_DIR/functions" "$TREEHOUSE_PLUGIN_DIR/functions/internal" "$TREEHOUSE_PLUGIN_DIR/completions" $fpath)
# Autoload all internal helper functions
autoload -Uz _gwt_repo _gwt_name _gwt_branch _gwt_path_for _gwt_current_path \
_gwt_has_fzf _gwt_has_tmux _gwt_has_direnv
# Autoload all user-facing commands
autoload -Uz gwt gwt-help gwt-list gwt-add gwt-switch gwt-open gwt-rm gwt-prune \
gwt-status gwt-main gwt-repo gwt-reload gwt-migrate gwt-clean gwt-mv gwt-pr gwt-diff gwt-stash-list \
gwt-archive gwt-unarchive gwt-archives gwt-lock gwt-unlock gwt-locks \
gwt-ignore gwt-unignore gwt-ignored gwt-excludes gwt-excludes-list gwt-excludes-edit
# Autoload completion functions
autoload -Uz _gwt _gwt_branches _gwt_clean_options
# Initialize completion system if not already done
if [[ -n "$ZSH_VERSION" ]]; then
if ! command -v compdef >/dev/null 2>&1; then
autoload -U compinit && compinit -q 2>/dev/null
fi
# Register completions (only if compdef is available)
if command -v compdef >/dev/null 2>&1; then
compdef _gwt gwt
compdef _gwt gwt-add
compdef _gwt gwt-switch
compdef _gwt gwt-rm
compdef _gwt gwt-open
compdef _gwt gwt-lock
compdef _gwt gwt-unlock
compdef _gwt gwt-archive
compdef _gwt gwt-unarchive
compdef _gwt gwt-mv
compdef _gwt gwt-diff
compdef _gwt gwt-clean
compdef _gwt gwt-pr
compdef _gwt gwt-repo
fi
fi
# Keep TREEHOUSE_PLUGIN_DIR exported for gwt-reload command (don't unset)