-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzsh-hookie-projects.plugin.zsh
More file actions
278 lines (237 loc) · 5.89 KB
/
zsh-hookie-projects.plugin.zsh
File metadata and controls
278 lines (237 loc) · 5.89 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/usr/bin/env zsh
# zsh-hookie-projects: Language-agnostic project detection with hooks
# Author: [Your Name]
# License: MIT
# Global state variables
typeset -g HOOKIE_CURRENT_PROJECT_DIR=""
typeset -ga HOOKIE_CURRENT_PROJECT_MARKERS=()
# Hookie-dir segment configuration (customizable in ~/.zshrc)
typeset -g HOOKIE_DIR_PARENT_COLOR=${HOOKIE_DIR_PARENT_COLOR:-240} # Dark gray
typeset -g HOOKIE_DIR_PROJECT_COLOR=${HOOKIE_DIR_PROJECT_COLOR:-6} # Cyan
typeset -g HOOKIE_DIR_SUBDIR_COLOR=${HOOKIE_DIR_SUBDIR_COLOR:-4} # Blue
typeset -g HOOKIE_DIR_SEPARATOR_COLOR=${HOOKIE_DIR_SEPARATOR_COLOR:-240} # Dark gray
typeset -g HOOKIE_DIR_DEFAULT_COLOR=${HOOKIE_DIR_DEFAULT_COLOR:-4} # Blue
typeset -g HOOKIE_DIR_SHORTEN_THRESHOLD=${HOOKIE_DIR_SHORTEN_THRESHOLD:-3} # When to start shortening
# Default project markers (customizable)
typeset -ga HOOKIE_PROJECT_MARKERS=(
# Version Control
'.git'
'.gitignore'
'.gitmodules'
# Python
'pyproject.toml'
'requirements.txt'
'setup.py'
'setup.cfg'
'Pipfile'
'poetry.lock'
'.venv'
'venv'
'env'
'.python-version'
'tox.ini'
'pytest.ini'
# Node.js/JavaScript
'package.json'
'package-lock.json'
'yarn.lock'
'pnpm-lock.yaml'
'.nvmrc'
'tsconfig.json'
'webpack.config.js'
'vite.config.js'
'rollup.config.js'
'.babelrc'
'.eslintrc.js'
'.eslintrc.json'
'.prettierrc'
'jest.config.js'
# Rust
'Cargo.toml'
'Cargo.lock'
# Go
'go.mod'
'go.sum'
'go.work'
# Java/JVM
'pom.xml'
'build.gradle'
'build.gradle.kts'
'gradle.properties'
'settings.gradle'
'build.sbt' # Scala
# C/C++
'Makefile'
'CMakeLists.txt'
'configure.ac'
'meson.build'
'conanfile.txt'
# PHP
'composer.json'
'composer.lock'
'phpunit.xml'
# Ruby
'Gemfile'
'Gemfile.lock'
'Rakefile'
'.ruby-version'
# Elixir
'mix.exs'
'mix.lock'
# Gleam
'gleam.toml'
# Deno
'deno.json'
'deno.jsonc'
# Swift
'Package.swift'
# Kotlin
'build.gradle.kts'
# Mobile Development
'pubspec.yaml' # Flutter/Dart
'android' # Android project
'ios' # iOS project
# Docker & Containers
'Dockerfile'
'docker-compose.yml'
'docker-compose.yaml'
'.dockerignore'
'Containerfile'
# Infrastructure as Code
'terraform'
'Terrafile'
'ansible'
'k8s'
'kubernetes'
'helm'
'Vagrantfile'
# CI/CD
'.github'
'.gitlab-ci.yml'
'.travis.yml'
'Jenkinsfile'
'.circleci'
'azure-pipelines.yml'
'.buildkite'
# Configuration Files
'.env'
'.env.local'
'.env.example'
'config.toml'
'config.yaml'
'config.yml'
'.editorconfig'
# Documentation
'README.md'
'README.rst'
'README.txt'
'CHANGELOG.md'
'CHANGELOG.rst'
'LICENSE'
'LICENSE.txt'
'LICENSE.md'
'CONTRIBUTING.md'
'CODE_OF_CONDUCT.md'
'docs'
# IDE/Editor Configuration
'.vscode'
'.idea'
'.vim'
'.nvim'
'.emacs.d'
# Linting & Formatting
'.flake8'
'.black'
'mypy.ini'
'pylint.rc'
'ruff.toml'
'.isort.cfg'
# Database
'schema.sql'
'migrations'
'seeds'
'alembic.ini' # Python SQLAlchemy
'knexfile.js' # Node.js Knex migrations
# Task Runners & Build Tools
'gulpfile.js'
'Gruntfile.js'
'webpack.config.js'
'babel.config.js'
'postcss.config.js'
'tailwind.config.js'
# Package Managers
'Brewfile' # Homebrew
'Pipfile' # Pipenv
'Podfile' # CocoaPods (iOS)
'flake.nix' # Nix
# Game Development
'project.godot' # Godot
'Assets' # Unity
# Data Science/ML
'requirements-dev.txt'
'environment.yml' # Conda
'notebook.ipynb'
'model.pkl'
# Web Frameworks
'next.config.js' # Next.js
'nuxt.config.js' # Nuxt.js
'svelte.config.js' # Svelte
'astro.config.mjs' # Astro
'remix.config.js' # Remix
# Static Site Generators
'_config.yml' # Jekyll
'hugo.toml' # Hugo
'gatsby-config.js' # Gatsby
# Monitoring & Observability
'prometheus.yml'
'grafana'
'jaeger'
# Custom
'.project-root'
)
# Path filtering configuration
typeset -ga HOOKIE_BLACKLIST_PATHS=(
"$HOME" # Home directory
"/" # Root directory
"/usr" # System directories
"/usr/local"
"/usr/share"
"/opt"
"/var"
"/etc"
"/tmp" # Temporary directories
"/System" # macOS system
"/Library" # macOS system
"$HOME/.local" # User local directories
"$HOME/.config" # User config directories
"$HOME/.cache"
"$HOME/.oh-my-zsh" # Oh My Zsh directory
"$HOME/.zinit" # Zinit directory
"$HOME/.zsh" # Zsh directories
)
# Optional: whitelist only specific directories (empty = disabled)
typeset -ga HOOKIE_WHITELIST_PATHS=(
# Examples (uncomment to enable whitelist mode):
# "$HOME/projects"
# "/workspace"
)
# Load all functions
local plugin_dir="${0:A:h}"
fpath=("$plugin_dir/functions" $fpath)
# Auto-load functions
autoload -Uz _hookie_find_project_root
autoload -Uz _hookie_detect_markers
autoload -Uz _hookie_check_project_change
autoload -Uz _hookie_is_path_allowed
autoload -Uz on_project_hook
autoload -Uz off_project_hook
autoload -Uz prompt_hookie_dir
autoload -Uz cd
# Hook into directory changes
chpwd_functions+=(_hookie_check_project_change)
# Initialize on plugin load
_hookie_check_project_change
# Ensure the hook runs before each prompt
if (( ! ${precmd_functions[(I)_hookie_check_project_change]} )); then
precmd_functions+=(_hookie_check_project_change)
fi