gitbash 0.2.7 → 1.1.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
@@ -7,7 +7,7 @@ Interactive git utilities for bash with fzf-powered menus.
7
7
  ### Via npm
8
8
 
9
9
  ```bash
10
- npm i -g gitbash
10
+ npm i -g gitbash && gitbash --config
11
11
  ```
12
12
 
13
13
  ### Options
package/bin/gitbash CHANGED
@@ -40,10 +40,102 @@ EOF
40
40
  echo
41
41
  echo "Saved configuration to $CONFIG_FILE"
42
42
 
43
+ # Check for dependencies
44
+ check_dependencies
45
+
43
46
  # Check for shell integration
44
47
  check_shell_integration
45
48
  }
46
49
 
50
+ # Check and offer to install dependencies
51
+ check_dependencies() {
52
+ local missing_required=()
53
+ local missing_optional=()
54
+
55
+ # Required dependencies
56
+ if ! command -v fzf >/dev/null 2>&1; then
57
+ missing_required+=("fzf")
58
+ fi
59
+
60
+ # Optional dependencies
61
+ if ! command -v delta >/dev/null 2>&1; then
62
+ missing_optional+=("git-delta")
63
+ fi
64
+ if ! command -v bat >/dev/null 2>&1; then
65
+ missing_optional+=("bat")
66
+ fi
67
+
68
+ # If nothing missing, we're done
69
+ if [[ ${#missing_required[@]} -eq 0 && ${#missing_optional[@]} -eq 0 ]]; then
70
+ echo
71
+ echo "All dependencies installed ✓"
72
+ return 0
73
+ fi
74
+
75
+ echo
76
+ echo "Dependencies:"
77
+
78
+ # Show status of each dependency
79
+ if command -v fzf >/dev/null 2>&1; then
80
+ echo " ✓ fzf (required)"
81
+ else
82
+ echo " ✗ fzf (required) - fuzzy finder for interactive selection"
83
+ fi
84
+
85
+ if command -v delta >/dev/null 2>&1; then
86
+ echo " ✓ git-delta (optional)"
87
+ else
88
+ echo " ✗ git-delta (optional) - better diff highlighting"
89
+ fi
90
+
91
+ if command -v bat >/dev/null 2>&1; then
92
+ echo " ✓ bat (optional)"
93
+ else
94
+ echo " ✗ bat (optional) - syntax highlighting for file previews"
95
+ fi
96
+
97
+ # Build list of all missing dependencies
98
+ local all_missing=()
99
+ [[ ${#missing_required[@]} -gt 0 ]] && all_missing+=("${missing_required[@]}")
100
+ [[ ${#missing_optional[@]} -gt 0 ]] && all_missing+=("${missing_optional[@]}")
101
+
102
+ # If nothing to install, we're done
103
+ if [[ ${#all_missing[@]} -eq 0 ]]; then
104
+ return 0
105
+ fi
106
+
107
+ # Check if Homebrew is available
108
+ if ! command -v brew >/dev/null 2>&1; then
109
+ echo
110
+ echo "Homebrew not found. Install dependencies manually:"
111
+ for dep in "${all_missing[@]}"; do
112
+ echo " brew install $dep"
113
+ done
114
+ return 0
115
+ fi
116
+
117
+ # Offer to install missing dependencies
118
+ echo
119
+ local install_deps
120
+ read -e -p "Install missing dependencies with Homebrew? (Y/n): " install_deps
121
+ case "$install_deps" in
122
+ [nN][oO]|[nN])
123
+ echo "Skipped dependency installation."
124
+ ;;
125
+ *)
126
+ echo "Installing dependencies..."
127
+ for dep in "${all_missing[@]}"; do
128
+ echo " Installing $dep..."
129
+ if brew install "$dep" 2>/dev/null; then
130
+ echo " ✓ $dep installed"
131
+ else
132
+ echo " ✗ Failed to install $dep"
133
+ fi
134
+ done
135
+ ;;
136
+ esac
137
+ }
138
+
47
139
  # Check if gitbash shell integration is set up
48
140
  check_shell_integration() {
49
141
  local shell_rc=""
@@ -32,3 +32,26 @@ prompt_read_edit() {
32
32
  read -e -rp "$prompt" "$varname"
33
33
  fi
34
34
  }
35
+
36
+ # Get the diff command to use (delta if installed, otherwise git diff)
37
+ # Usage: get_diff_cmd
38
+ # Returns the command name to use for diffs
39
+ get_diff_cmd() {
40
+ if command -v delta >/dev/null 2>&1; then
41
+ echo "delta --light"
42
+ else
43
+ echo "git diff"
44
+ fi
45
+ }
46
+
47
+ # Show a diff using delta if available, otherwise git diff
48
+ # Usage: show_diff [git diff args...]
49
+ # Example: show_diff --cached
50
+ # Example: show_diff HEAD~1
51
+ show_diff() {
52
+ if command -v delta >/dev/null 2>&1; then
53
+ git diff "$@" | delta --light
54
+ else
55
+ git diff "$@"
56
+ fi
57
+ }
@@ -176,12 +176,24 @@ EOF
176
176
  # -----------------------------
177
177
  case "$selection" in
178
178
  "$create_option")
179
+ # Source create.sh if create function not available
180
+ if ! declare -f create >/dev/null 2>&1; then
181
+ source "$SOURCE_DIR/create.sh"
182
+ fi
179
183
  create
180
184
  ;;
181
185
  "$switch_option")
186
+ # Source switch.sh if switch function not available
187
+ if ! declare -f switch >/dev/null 2>&1; then
188
+ source "$SOURCE_DIR/switch.sh"
189
+ fi
182
190
  switch
183
191
  ;;
184
192
  "$update_option")
193
+ # Source update.sh if update function not available
194
+ if ! declare -f update >/dev/null 2>&1; then
195
+ source "$SOURCE_DIR/update.sh"
196
+ fi
185
197
  update
186
198
  ;;
187
199
  "$abort_label")
@@ -126,7 +126,7 @@ EOF
126
126
  --preview='
127
127
  sel=$(echo {} | grep -o "stash@{[0-9]\+}" || true);
128
128
  if [[ -n "$sel" ]]; then
129
- git stash show -p "$sel";
129
+ git stash show -p "$sel" | delta --light 2>/dev/null || git stash show -p "$sel";
130
130
  else
131
131
  echo "No preview";
132
132
  fi
@@ -86,8 +86,11 @@ EOF
86
86
  esac
87
87
  done
88
88
 
89
- # Join message parts with spaces
90
- local msg="${msg_parts[*]}"
89
+ # Join message parts with spaces (handle empty array for set -u)
90
+ local msg=""
91
+ if [[ ${#msg_parts[@]} -gt 0 ]]; then
92
+ msg="${msg_parts[*]}"
93
+ fi
91
94
 
92
95
  # If no commit message was provided...
93
96
  if [ -z "$msg" ]; then
@@ -139,7 +139,7 @@ Showing last $count commits" \
139
139
  echo "";
140
140
  echo "─────────────────────────────────────────────────────";
141
141
  echo "";
142
- git show --color=always "$hash" 2>/dev/null | head -100;
142
+ git show --color=always "$hash" 2>/dev/null | head -100 | delta --light 2>/dev/null || git show --color=always "$hash" 2>/dev/null | head -100;
143
143
  fi
144
144
  ' \
145
145
  --preview-window=right:50% \
@@ -175,12 +175,24 @@ EOF
175
175
  # -----------------------------
176
176
  case "$selection" in
177
177
  "$stash_option")
178
+ # Source stash.sh if stash function not available
179
+ if ! declare -f stash >/dev/null 2>&1; then
180
+ source "$SOURCE_DIR/stash.sh"
181
+ fi
178
182
  stash
179
183
  ;;
180
184
  "$unstash_option")
185
+ # Source unstash.sh if unstash function not available
186
+ if ! declare -f unstash >/dev/null 2>&1; then
187
+ source "$SOURCE_DIR/unstash.sh"
188
+ fi
181
189
  unstash
182
190
  ;;
183
191
  "$cleanup_option")
192
+ # Source cleanstash.sh if cleanstash function not available
193
+ if ! declare -f cleanstash >/dev/null 2>&1; then
194
+ source "$SOURCE_DIR/cleanstash.sh"
195
+ fi
184
196
  cleanstash
185
197
  ;;
186
198
  "$abort_label")
@@ -156,23 +156,23 @@ EOF
156
156
  # Untracked file - show contents
157
157
  echo "=== UNTRACKED FILE ===";
158
158
  echo;
159
- bat --color=always --style=numbers "$file" 2>/dev/null || cat "$file" 2>/dev/null || echo "Cannot preview file";
159
+ bat --color=always --style=numbers --theme=\"GitHub\" "$file" 2>/dev/null || cat "$file" 2>/dev/null || echo "Cannot preview file";
160
160
  elif [[ "$file_status" =~ ^[MAC] ]]; then
161
161
  # Staged file - show cached diff
162
162
  echo "=== STAGED CHANGES ===";
163
163
  echo;
164
- git diff --cached --color=always "$file" 2>/dev/null | delta 2>/dev/null || git diff --cached --color=always "$file" 2>/dev/null;
164
+ git diff --cached --color=always "$file" 2>/dev/null | delta --light 2>/dev/null || git diff --cached --color=always "$file" 2>/dev/null;
165
165
  if git diff --color=always "$file" 2>/dev/null | grep -q .; then
166
166
  echo;
167
167
  echo "=== UNSTAGED CHANGES ===";
168
168
  echo;
169
- git diff --color=always "$file" 2>/dev/null | delta 2>/dev/null || git diff --color=always "$file" 2>/dev/null;
169
+ git diff --color=always "$file" 2>/dev/null | delta --light 2>/dev/null || git diff --color=always "$file" 2>/dev/null;
170
170
  fi
171
171
  else
172
172
  # Unstaged changes
173
173
  echo "=== UNSTAGED CHANGES ===";
174
174
  echo;
175
- git diff --color=always "$file" 2>/dev/null | delta 2>/dev/null || git diff --color=always "$file" 2>/dev/null;
175
+ git diff --color=always "$file" 2>/dev/null | delta --light 2>/dev/null || git diff --color=always "$file" 2>/dev/null;
176
176
  fi
177
177
  ' \
178
178
  --preview-window=right:60% \
@@ -326,6 +326,10 @@ EOF
326
326
  echo "Continuing..."
327
327
  ;;
328
328
  *)
329
+ # Source commit.sh if commit function not available
330
+ if ! declare -f commit >/dev/null 2>&1; then
331
+ source "$SOURCE_DIR/commit.sh"
332
+ fi
329
333
  # Use the commit function with staged and push flags
330
334
  commit -s -p
331
335
  break
@@ -129,7 +129,7 @@ EOF
129
129
  --preview='
130
130
  sel=$(echo {} | grep -o "stash@{[0-9]\+}" || true);
131
131
  if [[ -n "$sel" ]]; then
132
- git stash show -p "$sel";
132
+ git stash show -p "$sel" | delta --light 2>/dev/null || git stash show -p "$sel";
133
133
  else
134
134
  echo "No preview";
135
135
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitbash",
3
- "version": "0.2.7",
3
+ "version": "1.1.0",
4
4
  "description": "Opinionated git utilities for bash with fzf-powered menus",
5
5
  "author": "jaggli",
6
6
  "license": "MIT",