This commit is contained in:
parent
bc0d0ea889
commit
290da173f9
6
whatsdirty/dropshell-tool-config.json
Normal file
6
whatsdirty/dropshell-tool-config.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"aliases": [
|
||||
"whatsdirty"
|
||||
],
|
||||
"setup_script": "setup_script.sh"
|
||||
}
|
20
whatsdirty/install.sh
Normal file
20
whatsdirty/install.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
echo "Installing whatsdirty"
|
||||
|
||||
if ! command -v dropshell-tool ; then
|
||||
|
||||
ARCH=$(uname -m)
|
||||
wget "https://getbin.xyz/dropshell-tool:latest-${ARCH}" -O bootstrap && chmod a+x bootstrap
|
||||
./bootstrap install dropshell-tool
|
||||
rm ./bootstrap
|
||||
VERSION=$(dropshell-tool version)
|
||||
echo "Dropshell tool $VERSION installed"
|
||||
|
||||
fi
|
||||
|
||||
dropshell-tool install whatsdirty
|
15
whatsdirty/publish.sh
Normal file
15
whatsdirty/publish.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# run sos to upload
|
||||
"${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "${SCRIPT_DIR}/whatsdirty.sh" "whatsdirty:latest"
|
||||
"${SCRIPT_DIR}/../sos/sos" upload "getbin.xyz" "${SCRIPT_DIR}/install.sh" "whatsdirty-install:latest"
|
||||
|
||||
# publish the tool
|
||||
|
||||
mkdir -p ${SCRIPT_DIR}/tool
|
||||
cp ${SCRIPT_DIR}/whatsdirty.sh ${SCRIPT_DIR}/tool
|
||||
|
||||
|
||||
|
5
whatsdirty/setup_script.sh
Executable file
5
whatsdirty/setup_script.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "whatsdirty tool setup completed successfully!"
|
||||
echo "Use 'whatsdirty <directory>' to scan git repositories for uncommitted changes."
|
||||
echo "The specified directory will be saved for future use."
|
@ -227,5 +227,74 @@ main() {
|
||||
print_clean_repositories "$TEMP_FILE"
|
||||
}
|
||||
|
||||
# === Autocomplete Function ===
|
||||
|
||||
handle_autocomplete() {
|
||||
local cur_word="${COMP_WORDS[COMP_CWORD]}"
|
||||
local prev_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# If we're completing the first argument after 'whatsdirty'
|
||||
if [ ${COMP_CWORD} -eq 1 ]; then
|
||||
# Suggest common directories and saved directory
|
||||
local saved_dir=$(load_directory)
|
||||
local suggestions=""
|
||||
|
||||
# Add saved directory if it exists
|
||||
if [ -n "$saved_dir" ] && [ -d "$saved_dir" ]; then
|
||||
suggestions="$saved_dir"
|
||||
fi
|
||||
|
||||
# Add common development directories
|
||||
for dir in ~/code ~/projects ~/dev ~/src ~/workspace /home/*/code /home/*/projects; do
|
||||
if [ -d "$dir" ]; then
|
||||
# Only add if it contains git repositories
|
||||
if find "$dir" -maxdepth 2 -name ".git" -type d 2>/dev/null | head -1 | grep -q .; then
|
||||
suggestions="$suggestions $dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Directory completion for current word
|
||||
if [ -n "$cur_word" ]; then
|
||||
# Use compgen for directory completion
|
||||
local dir_completions=($(compgen -d -- "$cur_word"))
|
||||
# Add our suggestions that match the current word
|
||||
local matching_suggestions=($(echo "$suggestions" | tr ' ' '\n' | grep "^$cur_word" | sort -u))
|
||||
# Combine and deduplicate
|
||||
COMPREPLY=($(printf '%s\n' "${dir_completions[@]}" "${matching_suggestions[@]}" | sort -u))
|
||||
else
|
||||
# No current word, suggest all our directories plus general directory completion
|
||||
local dir_completions=($(compgen -d))
|
||||
local all_suggestions=($(echo "$suggestions" | tr ' ' '\n' | sort -u))
|
||||
# Combine and deduplicate, but limit to reasonable number
|
||||
COMPREPLY=($(printf '%s\n' "${all_suggestions[@]}" "${dir_completions[@]}" | sort -u | head -20))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if we're being called for autocomplete
|
||||
if [ "$1" = "autocomplete" ]; then
|
||||
# This is called when the tool is being used for bash completion
|
||||
# The arguments after 'autocomplete' are the completion context
|
||||
shift
|
||||
|
||||
# Set up COMP_WORDS and COMP_CWORD from arguments
|
||||
COMP_WORDS=("$@")
|
||||
COMP_CWORD=$(($# - 1))
|
||||
|
||||
# Generate completions
|
||||
handle_autocomplete
|
||||
|
||||
# Print completions, one per line
|
||||
printf '%s\n' "${COMPREPLY[@]}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if we're being called to show version
|
||||
if [ "$1" = "version" ]; then
|
||||
echo "whatsdirty 1.0.0"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Execute main function with all arguments
|
||||
main "$@"
|
Loading…
x
Reference in New Issue
Block a user