-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxgit
More file actions
43 lines (32 loc) · 1.16 KB
/
Copy pathxgit
File metadata and controls
43 lines (32 loc) · 1.16 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
#!/bin/bash
xgit() {
# Directory containing the command files (directory of this script)
COMMAND_DIR=$(dirname $functions_source[xgit])
# Get all available aliases
if [ -z "$1" ]; then
grep -h '^#' "$COMMAND_DIR"/xgit_bin/git_* | awk '/^# / {print $2}'
return 0
fi
# Get the alias from the first argument and shift to remaining arguments
alias="$1"; shift
# Find and execute the corresponding command file if it exists
command_file=$(grep -l "^# $alias" "$COMMAND_DIR"/xgit_bin/git_* | grep -v "$COMMAND_DIR/xgit$")
if [ -n "$command_file" ]; then
"$(basename "$command_file")" "$@"
else
echo "Alias '$alias' not found."
return 1
fi
}
_create_command_wrapper_for_function "xgit"
# _xgit_autocomplete() {
# local cur aliases
# cur="${words[CURRENT]}"
# # Capture the output of xgit and split it by newline
# aliases=("${(@f)$(xgit)}")
# # Remove the first element from the aliases array
# aliases=("${aliases[@]:0}")
# # Add the remaining aliases as autocomplete suggestions
# compadd -X 'Available commands:' -l -- $aliases
# }
# compdef _xgit_autocomplete xgit