gitbash 0.2.6 → 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 +1 -1
- package/bin/gitbash +153 -0
- package/commands/_utils.sh +23 -0
- package/commands/branch.sh +12 -0
- package/commands/cleanstash.sh +1 -1
- package/commands/cleanup.sh +0 -3
- package/commands/commit.sh +5 -2
- package/commands/commits.sh +1 -1
- package/commands/stashes.sh +12 -0
- package/commands/status.sh +8 -4
- package/commands/unstash.sh +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/gitbash
CHANGED
|
@@ -19,6 +19,7 @@ configure_gitbash() {
|
|
|
19
19
|
local current_merge="${GITBASH_MERGE_COMMAND:-fork}"
|
|
20
20
|
|
|
21
21
|
echo "Configure gitbash (writes to $CONFIG_FILE)"
|
|
22
|
+
echo
|
|
22
23
|
|
|
23
24
|
local input prefix merge_cmd
|
|
24
25
|
|
|
@@ -36,7 +37,159 @@ GITBASH_FEATURE_BRANCH_PREFIX="$prefix"
|
|
|
36
37
|
GITBASH_MERGE_COMMAND="$merge_cmd"
|
|
37
38
|
EOF
|
|
38
39
|
|
|
40
|
+
echo
|
|
39
41
|
echo "Saved configuration to $CONFIG_FILE"
|
|
42
|
+
|
|
43
|
+
# Check for dependencies
|
|
44
|
+
check_dependencies
|
|
45
|
+
|
|
46
|
+
# Check for shell integration
|
|
47
|
+
check_shell_integration
|
|
48
|
+
}
|
|
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
|
+
|
|
139
|
+
# Check if gitbash shell integration is set up
|
|
140
|
+
check_shell_integration() {
|
|
141
|
+
local shell_rc=""
|
|
142
|
+
local shell_files=("$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.bash_profile")
|
|
143
|
+
|
|
144
|
+
# Find the first existing shell rc file
|
|
145
|
+
for file in "${shell_files[@]}"; do
|
|
146
|
+
if [[ -f "$file" ]]; then
|
|
147
|
+
shell_rc="$file"
|
|
148
|
+
break
|
|
149
|
+
fi
|
|
150
|
+
done
|
|
151
|
+
|
|
152
|
+
if [[ -z "$shell_rc" ]]; then
|
|
153
|
+
echo
|
|
154
|
+
echo "No shell config file found (.zshrc, .bashrc, .bash_profile)"
|
|
155
|
+
return 0
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
# Check if gitbash integration already exists
|
|
159
|
+
local has_init=false
|
|
160
|
+
local has_alias=false
|
|
161
|
+
|
|
162
|
+
if grep -q 'eval.*gitbash --init' "$shell_rc" 2>/dev/null; then
|
|
163
|
+
has_init=true
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
if grep -q 'alias.*gitbash' "$shell_rc" 2>/dev/null; then
|
|
167
|
+
has_alias=true
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
# If neither init nor alias found, offer to add
|
|
171
|
+
if [[ "$has_init" == false && "$has_alias" == false ]]; then
|
|
172
|
+
echo
|
|
173
|
+
echo "Shell integration not found in $shell_rc"
|
|
174
|
+
local add_init
|
|
175
|
+
read -e -p "Add 'eval \"\$(gitbash --init)\"' to $shell_rc? (Y/n): " add_init
|
|
176
|
+
case "$add_init" in
|
|
177
|
+
[nN][oO]|[nN])
|
|
178
|
+
echo "Skipped shell integration."
|
|
179
|
+
;;
|
|
180
|
+
*)
|
|
181
|
+
echo >> "$shell_rc"
|
|
182
|
+
echo '# gitbash shell integration' >> "$shell_rc"
|
|
183
|
+
echo 'eval "$(gitbash --init)"' >> "$shell_rc"
|
|
184
|
+
echo
|
|
185
|
+
echo "Added to $shell_rc"
|
|
186
|
+
echo "Run 'source $shell_rc' or restart your shell to activate."
|
|
187
|
+
;;
|
|
188
|
+
esac
|
|
189
|
+
else
|
|
190
|
+
echo
|
|
191
|
+
echo "Shell integration already configured in $shell_rc"
|
|
192
|
+
fi
|
|
40
193
|
}
|
|
41
194
|
|
|
42
195
|
# Resolve symlinks to get the actual script location
|
package/commands/_utils.sh
CHANGED
|
@@ -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
|
+
}
|
package/commands/branch.sh
CHANGED
|
@@ -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")
|
package/commands/cleanstash.sh
CHANGED
|
@@ -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
|
package/commands/cleanup.sh
CHANGED
|
@@ -111,9 +111,6 @@ EOF
|
|
|
111
111
|
# -----------------------------
|
|
112
112
|
# 2. Fetch and prune to sync with remote
|
|
113
113
|
# -----------------------------
|
|
114
|
-
if [[ "$json_mode" == false ]]; then
|
|
115
|
-
echo "Fetching and pruning remote..."
|
|
116
|
-
fi
|
|
117
114
|
if ! git fetch --prune origin 2>/dev/null; then
|
|
118
115
|
if [[ "$json_mode" == false ]]; then
|
|
119
116
|
echo "⚠ Fetch failed; continuing with local data." >&2
|
package/commands/commit.sh
CHANGED
|
@@ -86,8 +86,11 @@ EOF
|
|
|
86
86
|
esac
|
|
87
87
|
done
|
|
88
88
|
|
|
89
|
-
# Join message parts with spaces
|
|
90
|
-
local msg="
|
|
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
|
package/commands/commits.sh
CHANGED
|
@@ -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% \
|
package/commands/stashes.sh
CHANGED
|
@@ -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")
|
package/commands/status.sh
CHANGED
|
@@ -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
|
package/commands/unstash.sh
CHANGED
|
@@ -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
|