diff --git a/README.md b/README.md index 83cf6520..2dc65470 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ curl -LsSf https://astral.sh/uv/install.sh | sh #### Method 1: Using install.sh (recommended)** > > [!NOTE] -> This method also setup autocomplete for bash/zsh shells automatically. +> This method also setup autocomplete for bash/zsh/fish shells automatically. ```bash cd ~/Downloads @@ -170,6 +170,37 @@ Changes to the source code will be reflected immediately without reinstalling. my-unicorn --help # to see the command options ``` +## Shell Completions + +### Bash / Zsh + +> [!NOTE] +> Completions are automatically configured when using `install.sh`. + +To manually enable: + +```bash +# Bash +sudo cp autocomplete/bash_autocomplete /etc/bash_completion.d/my-unicorn + +# Zsh +sudo cp autocomplete/zsh_autocomplete /usr/local/share/zsh/site-functions/_my-unicorn +``` + +### Fish shell + +> [!NOTE] +> Completions are automatically configured when using `install.sh`. + +To manually enable: + +```fish +mkdir -p ~/.config/fish/completions +cp completions/my-unicorn.fish ~/.config/fish/completions/ +``` + +Restart your shell or run `source ~/.config/fish/completions/my-unicorn.fish` to enable. + ## For using uncompatible apps (installing with URL) > [!IMPORTANT] diff --git a/completions/my-unicorn.fish b/completions/my-unicorn.fish new file mode 100644 index 00000000..0e775fa6 --- /dev/null +++ b/completions/my-unicorn.fish @@ -0,0 +1,102 @@ +# my-unicorn fish completion script +# ------------------------------------------------ +# Install: cp completions/my-unicorn.fish ~/.config/fish/completions/ +# ------------------------------------------------ + +complete -c my-unicorn -f + +# -- Global options ----------------------------------------------------------- + +complete -c my-unicorn -l version -d 'Show my-unicorn version and exit' +complete -c my-unicorn -s h -l help -d 'Show help message and exit' + +# -- Subcommands -------------------------------------------------------------- + +complete -c my-unicorn -n __fish_use_subcommand -a install -d 'Install AppImages from catalog or URLs' +complete -c my-unicorn -n __fish_use_subcommand -a update -d 'Update installed AppImages' +complete -c my-unicorn -n __fish_use_subcommand -a upgrade -d 'Upgrade my-unicorn CLI' +complete -c my-unicorn -n __fish_use_subcommand -a catalog -d 'Browse AppImage catalog' +complete -c my-unicorn -n __fish_use_subcommand -a migrate -d 'Migrate configs to latest version' +complete -c my-unicorn -n __fish_use_subcommand -a remove -d 'Remove installed AppImages' +complete -c my-unicorn -n __fish_use_subcommand -a backup -d 'Manage AppImage backups and restore' +complete -c my-unicorn -n __fish_use_subcommand -a cache -d 'Manage release data cache' +complete -c my-unicorn -n __fish_use_subcommand -a token -d 'Manage GitHub authentication token' +complete -c my-unicorn -n __fish_use_subcommand -a auth -d 'Show GitHub authentication status' +complete -c my-unicorn -n __fish_use_subcommand -a config -d 'Manage configuration' + +# -- install ------------------------------------------------------------------ + +complete -c my-unicorn -n '__fish_seen_subcommand_from install' -l concurrency -d 'Maximum number of parallel installs' -r +complete -c my-unicorn -n '__fish_seen_subcommand_from install' -l no-icon -d 'Skip downloading application icons' +complete -c my-unicorn -n '__fish_seen_subcommand_from install' -l no-verify -d 'Skip AppImage verification' +complete -c my-unicorn -n '__fish_seen_subcommand_from install' -l no-desktop -d 'Skip desktop entry creation' +complete -c my-unicorn -n '__fish_seen_subcommand_from install' -l verbose -d 'Show detailed logging during installation' +complete -c my-unicorn -n '__fish_seen_subcommand_from install' -s h -l help -d 'Show help message and exit' + +# -- update ------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from update' -l check-only -d 'Only check for updates without installing' +complete -c my-unicorn -n '__fish_seen_subcommand_from update' -l refresh-cache -d 'Bypass cache and fetch fresh data from GitHub API' +complete -c my-unicorn -n '__fish_seen_subcommand_from update' -l verbose -d 'Show detailed logging during update' +complete -c my-unicorn -n '__fish_seen_subcommand_from update' -s h -l help -d 'Show help message and exit' + +# -- upgrade ------------------------------------------------------------------ + +complete -c my-unicorn -n '__fish_seen_subcommand_from upgrade' -l check -d 'Check for available updates without performing the upgrade' +complete -c my-unicorn -n '__fish_seen_subcommand_from upgrade' -s h -l help -d 'Show help message and exit' + +# -- catalog ------------------------------------------------------------------ + +complete -c my-unicorn -n '__fish_seen_subcommand_from catalog' -l installed -d 'Show installed AppImages (default)' +complete -c my-unicorn -n '__fish_seen_subcommand_from catalog' -l available -d 'Show available applications from catalog with descriptions' +complete -c my-unicorn -n '__fish_seen_subcommand_from catalog' -l info -d 'Show detailed information about a specific app' -r +complete -c my-unicorn -n '__fish_seen_subcommand_from catalog' -s h -l help -d 'Show help message and exit' + +# -- migrate ------------------------------------------------------------------ + +complete -c my-unicorn -n '__fish_seen_subcommand_from migrate' -l dry-run -d 'Show what would be migrated without making changes' +complete -c my-unicorn -n '__fish_seen_subcommand_from migrate' -l force -d 'Force migration even if versions match' +complete -c my-unicorn -n '__fish_seen_subcommand_from migrate' -s h -l help -d 'Show help message and exit' + +# -- remove ------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from remove' -l keep-config -d 'Keep configuration files' +complete -c my-unicorn -n '__fish_seen_subcommand_from remove' -s h -l help -d 'Show help message and exit' + +# -- backup ------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from backup' -l restore-last -d 'Restore the latest backup version' +complete -c my-unicorn -n '__fish_seen_subcommand_from backup' -l restore-version -d 'Restore a specific version' -r +complete -c my-unicorn -n '__fish_seen_subcommand_from backup' -l list-backups -d 'List available backups for the specified app' +complete -c my-unicorn -n '__fish_seen_subcommand_from backup' -l cleanup -d 'Clean up old backups according to max_backup setting' +complete -c my-unicorn -n '__fish_seen_subcommand_from backup' -l info -d 'Show detailed backup information' +complete -c my-unicorn -n '__fish_seen_subcommand_from backup' -s h -l help -d 'Show help message and exit' + +# -- cache -------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from cache' -a clear -d 'Clear cache entries' +complete -c my-unicorn -n '__fish_seen_subcommand_from cache' -a stats -d 'Show cache statistics and storage info' +complete -c my-unicorn -n '__fish_seen_subcommand_from cache' -s h -l help -d 'Show help message and exit' + +# -- cache clear subcommand --------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from cache; and contains -- (commandline -opc); and not contains clear -- (commandline -opc); and not contains stats -- (commandline -opc)' -a clear -d 'Clear cache entries' +complete -c my-unicorn -n '__fish_seen_subcommand_from cache; and string match -q clear -- (commandline -opc)[2]' -l all -d 'Clear all cache entries' +complete -c my-unicorn -n '__fish_seen_subcommand_from cache; and string match -q clear -- (commandline -opc)[2]' -s h -l help -d 'Show help message and exit' + +# -- token -------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from token' -l save -d 'Save GitHub authentication token' +complete -c my-unicorn -n '__fish_seen_subcommand_from token' -l remove -d 'Remove GitHub authentication token' +complete -c my-unicorn -n '__fish_seen_subcommand_from token' -s h -l help -d 'Show help message and exit' + +# -- auth --------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from auth' -l status -d 'Show authentication status (default action)' +complete -c my-unicorn -n '__fish_seen_subcommand_from auth' -s h -l help -d 'Show help message and exit' + +# -- config ------------------------------------------------------------------- + +complete -c my-unicorn -n '__fish_seen_subcommand_from config' -l show -d 'Show current configuration' +complete -c my-unicorn -n '__fish_seen_subcommand_from config' -l reset -d 'Reset configuration to defaults' +complete -c my-unicorn -n '__fish_seen_subcommand_from config' -s h -l help -d 'Show help message and exit' diff --git a/install.sh b/install.sh index d7873147..a3225eb3 100755 --- a/install.sh +++ b/install.sh @@ -407,6 +407,7 @@ install_with_uv_tool() { check_local_bin_in_path setup_autocomplete_from_src "$src_dir" + setup_fish_completions copy_update_script print_info "✅ Installation complete using uv tool." @@ -442,32 +443,13 @@ install_with_uv_editable() { check_local_bin_in_path setup_autocomplete_from_src "$src_dir" + setup_fish_completions copy_update_script print_info "✅ Editable installation complete." print_info "Changes to source code will be reflected immediately." } -# ----------------------------------------------------------------------------- -# Uninstall support -# ----------------------------------------------------------------------------- - -# Remove everything installed by my-unicorn at user level. -# -# This includes: -# - uv tool installation -# - local update script -# - autocomplete install directory (optional cleanup) -# -# Safe behavior: -# - Only affects user-local files -# - Requires explicit confirmation -# - Never modifies system files -uninstall_my_unicorn() { - local src_dir - local confirm - - if ! src_dir="$(script_dir)"; then return 1 fi @@ -480,36 +462,12 @@ uninstall_my_unicorn() { print_info "❎ Uninstall cancelled." return 0 fi - - # 1. Remove uv tool install - if check_dependency "uv"; then - if uv tool list 2>/dev/null | grep -q "$CLI_NAME"; then - if ! uv tool uninstall "$CLI_NAME"; then - print_error "Failed to uninstall via uv tool." - return 1 fi print_info "đŸ—‘ī¸ Removed uv tool installation" else print_info "â„šī¸ uv tool installation not found" fi fi - - # 2. Remove update script - if [[ -f "$UPDATE_SCRIPT_PATH" ]]; then - if ! rm -f "$UPDATE_SCRIPT_PATH"; then - print_error "Failed to remove update script." - return 1 - fi - print_info "đŸ—‘ī¸ Removed update script: $UPDATE_SCRIPT_PATH" - fi - - # 3. Remove install directory (autocomplete + assets) - if [[ -d "$INSTALL_DIR" ]]; then - if ! rm -rf "$INSTALL_DIR"; then - print_error "Failed to remove install directory: $INSTALL_DIR" - return 1 - fi - print_info "đŸ—‘ī¸ Removed install directory: $INSTALL_DIR" fi cat <