gitbash 1.6.7 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,10 +15,12 @@ npm i -g gitbash && gitbash --config
15
15
  ### Options
16
16
 
17
17
  ```bash
18
- gitbash --help # Show help
19
- gitbash --version # Show version
20
- gitbash --init # Print shell init code
21
- gitbash --config # Interactive configuration wizard
18
+ gitbash --help # Show help
19
+ gitbash --version # Show version
20
+ gitbash --init # Print shell init code
21
+ gitbash --config # Interactive configuration wizard
22
+ gitbash --config-local # Configure local overrides for current repository
23
+ gitbash --config-user # Configure user-specific overrides (excluded from git)
22
24
  ```
23
25
 
24
26
  ### Dependencies
@@ -241,6 +243,30 @@ GITBASH_CLEANUP_DAYS=7
241
243
 
242
244
  You can create this file manually or use `gitbash --config` to configure interactively.
243
245
 
246
+ #### Local Configuration
247
+
248
+ gitbash also supports repository-specific configuration overrides. Run `gitbash --config-local` inside a git repository to create a `.gitbashrc` file in the repository root.
249
+
250
+ Local settings override the global `~/.gitbashrc` for that repository only. This is useful for:
251
+
252
+ - Different branch prefixes per project (e.g., team names)
253
+ - Project-specific issue parsing settings
254
+ - Different stale/cleanup thresholds per repository
255
+
256
+ The interactive wizard will show each setting's current global value and ask if you want to override it locally. Only overridden values are written to the local config.
257
+
258
+ #### User Configuration
259
+
260
+ For personal settings that should not be committed to version control, run `gitbash --config-user` to create a `.gitbashrc-user` file in the repository root.
261
+
262
+ User settings override both global (`~/.gitbashrc`) and local (`.gitbashrc`) settings. The file is automatically added to `.gitignore`.
263
+
264
+ **Configuration priority (highest to lowest):**
265
+
266
+ 1. `.gitbashrc-user` - User-specific settings (not committed)
267
+ 2. `.gitbashrc` - Repository settings (can be committed)
268
+ 3. `~/.gitbashrc` - Global settings
269
+
244
270
  ### Individual aliases
245
271
 
246
272
  Instead of adding every command via `eval "$(gitbash --init)"` in `.zshrc` or `.bashrc`
package/bin/gitbash CHANGED
@@ -4,12 +4,32 @@
4
4
  set -euo pipefail
5
5
 
6
6
  CONFIG_FILE="$HOME/.gitbashrc"
7
+ LOCAL_CONFIG_FILE=".gitbashrc"
8
+ USER_CONFIG_FILE=".gitbashrc-user"
7
9
 
8
10
  load_config() {
11
+ # Source global config first
9
12
  if [[ -f "$CONFIG_FILE" ]]; then
10
13
  # shellcheck disable=SC1090
11
14
  source "$CONFIG_FILE"
12
15
  fi
16
+
17
+ # Source local config from repo root if present (overrides global)
18
+ local repo_root
19
+ if repo_root=$(git rev-parse --show-toplevel 2>/dev/null); then
20
+ local local_config="$repo_root/$LOCAL_CONFIG_FILE"
21
+ if [[ -f "$local_config" ]]; then
22
+ # shellcheck disable=SC1090
23
+ source "$local_config"
24
+ fi
25
+
26
+ # Source user config from repo root if present (overrides both)
27
+ local user_config="$repo_root/$USER_CONFIG_FILE"
28
+ if [[ -f "$user_config" ]]; then
29
+ # shellcheck disable=SC1090
30
+ source "$user_config"
31
+ fi
32
+ fi
13
33
  }
14
34
 
15
35
  configure_gitbash() {
@@ -48,7 +68,7 @@ configure_gitbash() {
48
68
  if [[ -n "$current_prefix" ]]; then
49
69
  echo "Tip: Enter a single dash '-' to explicitly clear the prefix"
50
70
  fi
51
- read -e -p "Branch prefix [${current_prefix}]: " prefix
71
+ read -re -p "Branch prefix [${current_prefix}]: " prefix
52
72
  # If user just pressed Enter, keep current value
53
73
  # If user entered a single dash, clear it
54
74
  if [[ -z "$prefix" ]]; then
@@ -61,7 +81,7 @@ configure_gitbash() {
61
81
 
62
82
  # Merge tool
63
83
  echo
64
- read -e -p "Merge tool command (used by update on conflicts) [${current_merge}]: " input
84
+ read -re -p "Merge tool command (used by update on conflicts) [${current_merge}]: " input
65
85
  merge_cmd=${input:-$current_merge}
66
86
 
67
87
  # Issue parsing
@@ -72,7 +92,7 @@ configure_gitbash() {
72
92
  current_enabled="no"
73
93
  fi
74
94
 
75
- read -e -p "Enable Jira issue parsing in branch names? (yes/no) [${current_enabled}]: " input
95
+ read -re -p "Enable Jira issue parsing in branch names? (yes/no) [${current_enabled}]: " input
76
96
  local enable_parsing=${input:-$current_enabled}
77
97
 
78
98
  # Convert answer to no_issue_parsing variable (inverted logic)
@@ -91,7 +111,7 @@ configure_gitbash() {
91
111
 
92
112
  # Issue parsing fallback (only ask if parsing is enabled)
93
113
  if [[ "$enable_parsing" == "yes" ]]; then
94
- read -e -p "Fallback prefix when no issue number is provided [${current_issue_fallback}]: " input
114
+ read -re -p "Fallback prefix when no issue number is provided [${current_issue_fallback}]: " input
95
115
  issue_fallback=${input:-$current_issue_fallback}
96
116
  else
97
117
  issue_fallback="${current_issue_fallback}"
@@ -103,7 +123,7 @@ configure_gitbash() {
103
123
  echo " auto - Use terminal's theme detection"
104
124
  echo " dark - Force dark theme"
105
125
  echo " light - Force light theme (GitHub style)"
106
- read -e -p "Theme [${current_theme}]: " input
126
+ read -re -p "Theme [${current_theme}]: " input
107
127
  theme=${input:-$current_theme}
108
128
  case "$theme" in
109
129
  auto|dark|light) ;;
@@ -115,7 +135,7 @@ configure_gitbash() {
115
135
 
116
136
  # Stale branch threshold
117
137
  echo
118
- read -e -p "Stale branch threshold in months (used by stale) [${current_stale_months}]: " input
138
+ read -re -p "Stale branch threshold in months (used by stale) [${current_stale_months}]: " input
119
139
  stale_months=${input:-$current_stale_months}
120
140
  if ! [[ "$stale_months" =~ ^[0-9]+$ ]] || [[ "$stale_months" -lt 1 ]]; then
121
141
  echo "Invalid value. Using default of 3 months."
@@ -123,7 +143,7 @@ configure_gitbash() {
123
143
  fi
124
144
 
125
145
  # Cleanup threshold
126
- read -e -p "Cleanup threshold in days (used by cleanup) [${current_cleanup_days}]: " input
146
+ read -re -p "Cleanup threshold in days (used by cleanup) [${current_cleanup_days}]: " input
127
147
  cleanup_days=${input:-$current_cleanup_days}
128
148
  if ! [[ "$cleanup_days" =~ ^[0-9]+$ ]] || [[ "$cleanup_days" -lt 1 ]]; then
129
149
  echo "Invalid value. Using default of 7 days."
@@ -171,6 +191,374 @@ EOF
171
191
  check_shell_integration
172
192
  }
173
193
 
194
+ configure_local_gitbash() {
195
+ # Check if we're in a git repository
196
+ local repo_root
197
+ if ! repo_root=$(git rev-parse --show-toplevel 2>/dev/null); then
198
+ echo "Error: Not inside a git repository." >&2
199
+ exit 1
200
+ fi
201
+
202
+ local local_config="$repo_root/$LOCAL_CONFIG_FILE"
203
+
204
+ # Load global config first to get current defaults
205
+ load_config
206
+
207
+ # Backward compatibility: migrate GITBASH_FEATURE_BRANCH_PREFIX to GITBASH_CREATE_BRANCH_PREFIX
208
+ local current_prefix="${GITBASH_CREATE_BRANCH_PREFIX:-}"
209
+ if [[ -z "$current_prefix" && -n "${GITBASH_FEATURE_BRANCH_PREFIX:-}" ]]; then
210
+ # Remove "feature/" prefix from old variable
211
+ current_prefix="${GITBASH_FEATURE_BRANCH_PREFIX#feature/}"
212
+ fi
213
+ # Remove trailing slash if present
214
+ current_prefix="${current_prefix%/}"
215
+
216
+ echo "Configure local gitbash overrides for this repository"
217
+ echo "Config will be saved to: $local_config"
218
+ echo
219
+ echo "Press Enter to keep global setting, or enter a new value to override."
220
+ echo "Enter '-' to explicitly unset a local override."
221
+ echo
222
+
223
+ local overrides=()
224
+ local input
225
+
226
+ # Branch prefix (current_prefix already set above with backward compatibility)
227
+ echo "1. Branch prefix"
228
+ echo " Current (global): ${current_prefix:-'(empty)'}"
229
+ read -re -p " Local override: " input
230
+ if [[ -n "$input" ]]; then
231
+ if [[ "$input" == "-" ]]; then
232
+ overrides+=("GITBASH_CREATE_BRANCH_PREFIX=\"\"")
233
+ echo " → Will use empty prefix locally"
234
+ else
235
+ input="${input%/}" # Remove trailing slash
236
+ overrides+=("GITBASH_CREATE_BRANCH_PREFIX=\"$input\"")
237
+ echo " → Will use '$input' locally"
238
+ fi
239
+ else
240
+ echo " → Keeping global setting"
241
+ fi
242
+ echo
243
+
244
+ # Merge command
245
+ local current_merge="${GITBASH_MERGE_COMMAND:-fork}"
246
+ echo "2. Merge tool command (used by update on conflicts)"
247
+ echo " Current (global): $current_merge"
248
+ read -re -p " Local override: " input
249
+ if [[ -n "$input" && "$input" != "-" ]]; then
250
+ overrides+=("GITBASH_MERGE_COMMAND=\"$input\"")
251
+ echo " → Will use '$input' locally"
252
+ else
253
+ echo " → Keeping global setting"
254
+ fi
255
+ echo
256
+
257
+ # Issue parsing
258
+ local current_no_issue_parsing="${GITBASH_CREATE_NO_ISSUE_PARSING:-no}"
259
+ local current_enabled="yes"
260
+ [[ "$current_no_issue_parsing" == "yes" ]] && current_enabled="no"
261
+ echo "3. Enable Jira issue parsing in branch names? (yes/no)"
262
+ echo " Current (global): $current_enabled"
263
+ read -re -p " Local override: " input
264
+ if [[ -n "$input" && "$input" != "-" ]]; then
265
+ case "$input" in
266
+ yes)
267
+ overrides+=("GITBASH_CREATE_NO_ISSUE_PARSING=\"no\"")
268
+ echo " → Will enable parsing locally"
269
+ ;;
270
+ no)
271
+ overrides+=("GITBASH_CREATE_NO_ISSUE_PARSING=\"yes\"")
272
+ echo " → Will disable parsing locally"
273
+ ;;
274
+ *)
275
+ echo " → Invalid value, keeping global setting"
276
+ ;;
277
+ esac
278
+ else
279
+ echo " → Keeping global setting"
280
+ fi
281
+ echo
282
+
283
+ # Issue fallback
284
+ local current_issue_fallback="${GITBASH_CREATE_ISSUE_PARSING_FALLBACK:-NOISSUE}"
285
+ echo "4. Fallback prefix when no issue number is provided"
286
+ echo " Current (global): $current_issue_fallback"
287
+ read -re -p " Local override: " input
288
+ if [[ -n "$input" && "$input" != "-" ]]; then
289
+ overrides+=("GITBASH_CREATE_ISSUE_PARSING_FALLBACK=\"$input\"")
290
+ echo " → Will use '$input' locally"
291
+ else
292
+ echo " → Keeping global setting"
293
+ fi
294
+ echo
295
+
296
+ # Theme
297
+ local current_theme="${GITBASH_THEME:-auto}"
298
+ echo "5. Theme for delta/bat (auto/dark/light)"
299
+ echo " Current (global): $current_theme"
300
+ read -re -p " Local override: " input
301
+ if [[ -n "$input" && "$input" != "-" ]]; then
302
+ case "$input" in
303
+ auto|dark|light)
304
+ overrides+=("GITBASH_THEME=\"$input\"")
305
+ echo " → Will use '$input' locally"
306
+ ;;
307
+ *)
308
+ echo " → Invalid value, keeping global setting"
309
+ ;;
310
+ esac
311
+ else
312
+ echo " → Keeping global setting"
313
+ fi
314
+ echo
315
+
316
+ # Stale months
317
+ local current_stale_months="${GITBASH_STALE_MONTHS:-3}"
318
+ echo "6. Stale branch threshold in months"
319
+ echo " Current (global): $current_stale_months"
320
+ read -re -p " Local override: " input
321
+ if [[ -n "$input" && "$input" != "-" ]]; then
322
+ if [[ "$input" =~ ^[0-9]+$ ]] && [[ "$input" -ge 1 ]]; then
323
+ overrides+=("GITBASH_STALE_MONTHS=\"$input\"")
324
+ echo " → Will use '$input' locally"
325
+ else
326
+ echo " → Invalid value, keeping global setting"
327
+ fi
328
+ else
329
+ echo " → Keeping global setting"
330
+ fi
331
+ echo
332
+
333
+ # Cleanup days
334
+ local current_cleanup_days="${GITBASH_CLEANUP_DAYS:-7}"
335
+ echo "7. Cleanup threshold in days"
336
+ echo " Current (global): $current_cleanup_days"
337
+ read -re -p " Local override: " input
338
+ if [[ -n "$input" && "$input" != "-" ]]; then
339
+ if [[ "$input" =~ ^[0-9]+$ ]] && [[ "$input" -ge 1 ]]; then
340
+ overrides+=("GITBASH_CLEANUP_DAYS=\"$input\"")
341
+ echo " → Will use '$input' locally"
342
+ else
343
+ echo " → Invalid value, keeping global setting"
344
+ fi
345
+ else
346
+ echo " → Keeping global setting"
347
+ fi
348
+ echo
349
+
350
+ # Check if any overrides were set
351
+ if [[ ${#overrides[@]} -eq 0 ]]; then
352
+ echo "No local overrides configured."
353
+ return 0
354
+ fi
355
+
356
+ # Write local config file
357
+ {
358
+ echo "# Local gitbash configuration overrides for this repository"
359
+ echo "# Generated by 'gitbash --config-local'"
360
+ echo "# These settings override the global ~/.gitbashrc"
361
+ echo
362
+ for override in "${overrides[@]}"; do
363
+ echo "$override"
364
+ done
365
+ } > "$local_config"
366
+
367
+ echo "Saved local configuration to $local_config"
368
+ }
369
+
370
+ configure_user_gitbash() {
371
+ # Check if we're in a git repository
372
+ local repo_root
373
+ if ! repo_root=$(git rev-parse --show-toplevel 2>/dev/null); then
374
+ echo "Error: Not inside a git repository." >&2
375
+ exit 1
376
+ fi
377
+
378
+ local user_config="$repo_root/$USER_CONFIG_FILE"
379
+ local gitignore="$repo_root/.gitignore"
380
+
381
+ # Load all configs to get current effective values
382
+ load_config
383
+
384
+ # Backward compatibility: migrate GITBASH_FEATURE_BRANCH_PREFIX to GITBASH_CREATE_BRANCH_PREFIX
385
+ local current_prefix="${GITBASH_CREATE_BRANCH_PREFIX:-}"
386
+ if [[ -z "$current_prefix" && -n "${GITBASH_FEATURE_BRANCH_PREFIX:-}" ]]; then
387
+ # Remove "feature/" prefix from old variable
388
+ current_prefix="${GITBASH_FEATURE_BRANCH_PREFIX#feature/}"
389
+ fi
390
+ # Remove trailing slash if present
391
+ current_prefix="${current_prefix%/}"
392
+
393
+ echo "Configure user-specific gitbash overrides for this repository"
394
+ echo "Config will be saved to: $user_config"
395
+ echo "This file is intended for personal settings and excluded from version control."
396
+ echo
397
+ echo "Press Enter to keep current setting, or enter a new value to override."
398
+ echo "Enter '-' to explicitly unset an override."
399
+ echo
400
+
401
+ local overrides=()
402
+ local input
403
+
404
+ # Branch prefix
405
+ echo "1. Branch prefix"
406
+ echo " Current (effective): ${current_prefix:-'(empty)'}"
407
+ read -re -p " User override: " input
408
+ if [[ -n "$input" ]]; then
409
+ if [[ "$input" == "-" ]]; then
410
+ overrides+=("GITBASH_CREATE_BRANCH_PREFIX=\"\"")
411
+ echo " → Will use empty prefix"
412
+ else
413
+ input="${input%/}" # Remove trailing slash
414
+ overrides+=("GITBASH_CREATE_BRANCH_PREFIX=\"$input\"")
415
+ echo " → Will use '$input'"
416
+ fi
417
+ else
418
+ echo " → Keeping current setting"
419
+ fi
420
+ echo
421
+
422
+ # Merge command
423
+ local current_merge="${GITBASH_MERGE_COMMAND:-fork}"
424
+ echo "2. Merge tool command (used by update on conflicts)"
425
+ echo " Current (effective): $current_merge"
426
+ read -re -p " User override: " input
427
+ if [[ -n "$input" && "$input" != "-" ]]; then
428
+ overrides+=("GITBASH_MERGE_COMMAND=\"$input\"")
429
+ echo " → Will use '$input'"
430
+ else
431
+ echo " → Keeping current setting"
432
+ fi
433
+ echo
434
+
435
+ # Issue parsing
436
+ local current_no_issue_parsing="${GITBASH_CREATE_NO_ISSUE_PARSING:-no}"
437
+ local current_enabled="yes"
438
+ [[ "$current_no_issue_parsing" == "yes" ]] && current_enabled="no"
439
+ echo "3. Enable Jira issue parsing in branch names? (yes/no)"
440
+ echo " Current (effective): $current_enabled"
441
+ read -re -p " User override: " input
442
+ if [[ -n "$input" && "$input" != "-" ]]; then
443
+ case "$input" in
444
+ yes)
445
+ overrides+=("GITBASH_CREATE_NO_ISSUE_PARSING=\"no\"")
446
+ echo " → Will enable parsing"
447
+ ;;
448
+ no)
449
+ overrides+=("GITBASH_CREATE_NO_ISSUE_PARSING=\"yes\"")
450
+ echo " → Will disable parsing"
451
+ ;;
452
+ *)
453
+ echo " → Invalid value, keeping current setting"
454
+ ;;
455
+ esac
456
+ else
457
+ echo " → Keeping current setting"
458
+ fi
459
+ echo
460
+
461
+ # Issue fallback
462
+ local current_issue_fallback="${GITBASH_CREATE_ISSUE_PARSING_FALLBACK:-NOISSUE}"
463
+ echo "4. Fallback prefix when no issue number is provided"
464
+ echo " Current (effective): $current_issue_fallback"
465
+ read -re -p " User override: " input
466
+ if [[ -n "$input" && "$input" != "-" ]]; then
467
+ overrides+=("GITBASH_CREATE_ISSUE_PARSING_FALLBACK=\"$input\"")
468
+ echo " → Will use '$input'"
469
+ else
470
+ echo " → Keeping current setting"
471
+ fi
472
+ echo
473
+
474
+ # Theme
475
+ local current_theme="${GITBASH_THEME:-auto}"
476
+ echo "5. Theme for delta/bat (auto/dark/light)"
477
+ echo " Current (effective): $current_theme"
478
+ read -re -p " User override: " input
479
+ if [[ -n "$input" && "$input" != "-" ]]; then
480
+ case "$input" in
481
+ auto|dark|light)
482
+ overrides+=("GITBASH_THEME=\"$input\"")
483
+ echo " → Will use '$input'"
484
+ ;;
485
+ *)
486
+ echo " → Invalid value, keeping current setting"
487
+ ;;
488
+ esac
489
+ else
490
+ echo " → Keeping current setting"
491
+ fi
492
+ echo
493
+
494
+ # Stale months
495
+ local current_stale_months="${GITBASH_STALE_MONTHS:-3}"
496
+ echo "6. Stale branch threshold in months"
497
+ echo " Current (effective): $current_stale_months"
498
+ read -re -p " User override: " input
499
+ if [[ -n "$input" && "$input" != "-" ]]; then
500
+ if [[ "$input" =~ ^[0-9]+$ ]] && [[ "$input" -ge 1 ]]; then
501
+ overrides+=("GITBASH_STALE_MONTHS=\"$input\"")
502
+ echo " → Will use '$input'"
503
+ else
504
+ echo " → Invalid value, keeping current setting"
505
+ fi
506
+ else
507
+ echo " → Keeping current setting"
508
+ fi
509
+ echo
510
+
511
+ # Cleanup days
512
+ local current_cleanup_days="${GITBASH_CLEANUP_DAYS:-7}"
513
+ echo "7. Cleanup threshold in days"
514
+ echo " Current (effective): $current_cleanup_days"
515
+ read -re -p " User override: " input
516
+ if [[ -n "$input" && "$input" != "-" ]]; then
517
+ if [[ "$input" =~ ^[0-9]+$ ]] && [[ "$input" -ge 1 ]]; then
518
+ overrides+=("GITBASH_CLEANUP_DAYS=\"$input\"")
519
+ echo " → Will use '$input'"
520
+ else
521
+ echo " → Invalid value, keeping current setting"
522
+ fi
523
+ else
524
+ echo " → Keeping current setting"
525
+ fi
526
+ echo
527
+
528
+ # Check if any overrides were set
529
+ if [[ ${#overrides[@]} -eq 0 ]]; then
530
+ echo "No user overrides configured."
531
+ return 0
532
+ fi
533
+
534
+ # Write user config file
535
+ {
536
+ echo "# User-specific gitbash configuration overrides for this repository"
537
+ echo "# Generated by 'gitbash --config-user'"
538
+ echo "# These settings override both global (~/.gitbashrc) and local (.gitbashrc) settings"
539
+ echo "# This file should NOT be committed to version control"
540
+ echo
541
+ for override in "${overrides[@]}"; do
542
+ echo "$override"
543
+ done
544
+ } > "$user_config"
545
+
546
+ echo "Saved user configuration to $user_config"
547
+
548
+ # Add to .gitignore if not already present
549
+ if [[ -f "$gitignore" ]]; then
550
+ if ! grep -qxF "$USER_CONFIG_FILE" "$gitignore"; then
551
+ echo "$USER_CONFIG_FILE" >> "$gitignore"
552
+ echo "Added '$USER_CONFIG_FILE' to .gitignore"
553
+ else
554
+ echo "'$USER_CONFIG_FILE' already in .gitignore"
555
+ fi
556
+ else
557
+ echo "$USER_CONFIG_FILE" > "$gitignore"
558
+ echo "Created .gitignore with '$USER_CONFIG_FILE'"
559
+ fi
560
+ }
561
+
174
562
  # Check and offer to install dependencies
175
563
  check_dependencies() {
176
564
  local missing_required=()
@@ -241,7 +629,7 @@ check_dependencies() {
241
629
  # Offer to install missing dependencies
242
630
  echo
243
631
  local install_deps
244
- read -e -p "Install missing dependencies with Homebrew? (Y/n): " install_deps
632
+ read -re -p "Install missing dependencies with Homebrew? (Y/n): " install_deps
245
633
  case "$install_deps" in
246
634
  [nN][oO]|[nN])
247
635
  echo "Skipped dependency installation."
@@ -296,7 +684,7 @@ check_shell_integration() {
296
684
  echo
297
685
  echo "Shell integration not found in $shell_rc"
298
686
  local add_init
299
- read -e -p "Add 'eval \"\$(gitbash --init)\"' to $shell_rc? (Y/n): " add_init
687
+ read -re -p "Add 'eval \"\$(gitbash --init)\"' to $shell_rc? (Y/n): " add_init
300
688
  case "$add_init" in
301
689
  [nN][oO]|[nN])
302
690
  echo "Skipped shell integration."
@@ -358,6 +746,8 @@ Usage:
358
746
  gitbash --help
359
747
  gitbash --init
360
748
  gitbash --config
749
+ gitbash --config-local
750
+ gitbash --config-user
361
751
 
362
752
  Commands:
363
753
  branch Interactive menu for branch operations
@@ -376,10 +766,12 @@ Commands:
376
766
  update Merge latest main/master into current branch
377
767
 
378
768
  Options:
379
- -h, --help Show this help message
380
- -v, --version Show version number
381
- --init Print shell initialization code (for sourcing)
382
- --config Configure gitbash and save to ~/.gitbashrc
769
+ -h, --help Show this help message
770
+ -v, --version Show version number
771
+ --init Print shell initialization code (for sourcing)
772
+ --config Configure gitbash and save to ~/.gitbashrc
773
+ --config-local Configure local overrides for current repository
774
+ --config-user Configure user-specific overrides (excluded from git)
383
775
 
384
776
  Examples:
385
777
  gitbash commit fix bug -p # Commit and push
@@ -438,6 +830,14 @@ main() {
438
830
  configure_gitbash
439
831
  exit 0
440
832
  ;;
833
+ --config-local)
834
+ configure_local_gitbash
835
+ exit 0
836
+ ;;
837
+ --config-user)
838
+ configure_user_gitbash
839
+ exit 0
840
+ ;;
441
841
  *)
442
842
  local cmd="$1"
443
843
  shift
@@ -2,13 +2,31 @@
2
2
  # shellcheck disable=SC2155
3
3
  # Common utilities for gitbash commands - compatible with bash and zsh
4
4
 
5
- # Load config file if it exists
5
+ # Load config files if they exist
6
+ # Global config first, then local repo config, then user config (which can override)
6
7
  CONFIG_FILE="$HOME/.gitbashrc"
8
+ LOCAL_CONFIG_FILE=".gitbashrc"
9
+ USER_CONFIG_FILE=".gitbashrc-user"
10
+
7
11
  if [[ -f "$CONFIG_FILE" ]]; then
8
12
  # shellcheck disable=SC1090
9
13
  source "$CONFIG_FILE"
10
14
  fi
11
15
 
16
+ # Source local config from repo root if present (overrides global)
17
+ _repo_root=$(git rev-parse --show-toplevel 2>/dev/null)
18
+ if [[ -n "$_repo_root" && -f "$_repo_root/$LOCAL_CONFIG_FILE" ]]; then
19
+ # shellcheck disable=SC1090
20
+ source "$_repo_root/$LOCAL_CONFIG_FILE"
21
+ fi
22
+
23
+ # Source user config from repo root if present (overrides both)
24
+ if [[ -n "$_repo_root" && -f "$_repo_root/$USER_CONFIG_FILE" ]]; then
25
+ # shellcheck disable=SC1090
26
+ source "$_repo_root/$USER_CONFIG_FILE"
27
+ fi
28
+ unset _repo_root
29
+
12
30
  # Color codes for consistent output
13
31
  COLOR_RED='\033[0;31m'
14
32
  COLOR_GREEN='\033[0;32m'
package/commands/pr.sh CHANGED
@@ -1,4 +1,5 @@
1
1
  ## pr opens the current pr, if in repo
2
+ # shellcheck shell=bash
2
3
  pr() {
3
4
  local should_push=false
4
5
 
@@ -87,6 +88,7 @@ EOF
87
88
  source "$SOURCE_DIR/_utils.sh"
88
89
  fi
89
90
 
91
+ local commit_answer
90
92
  prompt_read "Would you like to commit them first? (Y/n): " commit_answer
91
93
  case "$commit_answer" in
92
94
  [nN][oO]|[nN])
@@ -94,24 +96,33 @@ EOF
94
96
  ;;
95
97
  *)
96
98
  # Run status command for interactive staging and committing
97
- gitbash status
98
- if [[ $? -ne 0 ]]; then
99
+ local local_before
100
+ local local_after
101
+ local_before=$(git rev-parse --verify HEAD 2>/dev/null || true)
102
+ if ! gitbash status; then
99
103
  echo "Commit cancelled or failed. Aborting PR creation."
100
104
  return 1
101
105
  fi
102
-
103
- # If -p wasn't specified, offer to push the fresh commit
104
- if [[ "$should_push" != true ]]; then
105
- echo ""
106
- prompt_read "Push the fresh commit to origin? (Y/n): " push_answer
107
- case "$push_answer" in
108
- [nN][oO]|[nN])
109
- echo "Continuing without pushing..."
110
- ;;
111
- *)
112
- should_push=true
113
- ;;
114
- esac
106
+ local_after=$(git rev-parse --verify HEAD 2>/dev/null || true)
107
+
108
+ # Only offer to push if a new commit was actually created
109
+ if [[ "$local_after" != "$local_before" ]]; then
110
+ # If -p wasn't specified, offer to push the fresh commit
111
+ if [[ "$should_push" != true ]]; then
112
+ local push_answer
113
+ echo ""
114
+ prompt_read "Push the fresh commit to origin? (Y/n): " push_answer
115
+ case "$push_answer" in
116
+ [nN][oO]|[nN])
117
+ echo "Continuing without pushing..."
118
+ ;;
119
+ *)
120
+ should_push=true
121
+ ;;
122
+ esac
123
+ fi
124
+ else
125
+ echo "No new commit was created. Continuing without pushing..."
115
126
  fi
116
127
  ;;
117
128
  esac
@@ -138,15 +149,16 @@ EOF
138
149
  if [[ "$should_push" == true ]]; then
139
150
  # Check if remote has updates and pull first
140
151
  git fetch origin "$branch" 2>/dev/null
141
- local local_commit=$(git rev-parse HEAD)
142
- local remote_commit=$(git rev-parse "origin/$branch" 2>/dev/null)
152
+ local local_commit
153
+ local remote_commit
154
+ local_commit=$(git rev-parse HEAD)
155
+ remote_commit=$(git rev-parse "origin/$branch" 2>/dev/null)
143
156
 
144
157
  if [[ -n "$remote_commit" && "$local_commit" != "$remote_commit" ]]; then
145
158
  # Check if we're behind the remote
146
159
  if git merge-base --is-ancestor "$local_commit" "$remote_commit" 2>/dev/null; then
147
160
  echo "Remote has updates. Pulling first..."
148
- git pull --rebase origin "$branch"
149
- if [[ $? -ne 0 ]]; then
161
+ if ! git pull --rebase origin "$branch"; then
150
162
  echo "⚠ Failed to pull remote changes. Please resolve conflicts and try again."
151
163
  return 1
152
164
  fi
@@ -155,7 +167,7 @@ EOF
155
167
  # Branches have diverged
156
168
  echo "Remote has diverged. Pulling with rebase..."
157
169
  git pull --rebase origin "$branch"
158
- if [[ $? -ne 0 ]]; then
170
+ if ! git pull --rebase origin "$branch"; then
159
171
  echo "⚠ Failed to pull remote changes. Please resolve conflicts and try again."
160
172
  return 1
161
173
  fi
@@ -164,8 +176,7 @@ EOF
164
176
  fi
165
177
 
166
178
  echo "Pushing '$branch' to origin..."
167
- git push origin "$branch"
168
- if [[ $? -eq 0 ]]; then
179
+ if git push origin "$branch"; then
169
180
  echo "✓ Successfully pushed '$branch' to origin."
170
181
  else
171
182
  echo "⚠ Failed to push '$branch' to origin."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitbash",
3
- "version": "1.6.7",
3
+ "version": "1.8.0",
4
4
  "description": "Opinionated git utilities for bash with fzf-powered menus",
5
5
  "author": "jaggli",
6
6
  "license": "MIT",