diff --git a/config/zsh/completion/_dfm b/config/zsh/completion/_dfm index 1d2e55c..e7112ac 100644 --- a/config/zsh/completion/_dfm +++ b/config/zsh/completion/_dfm @@ -1,6 +1,29 @@ #compdef dfm +# Completion for dfm, the dotfiles manager -_dfm() { +_dfm_get_script_description() { + local file="$1" + sed -n '/@description/s/.*@description *\(.*\)/\1/p' "$file" | head -1 +} + +_dfm_get_available_scripts() { + local scripts=() + local dotfiles="${HOME}/.dotfiles" + + for script in "${dotfiles}/scripts/install-"*.sh; do + if [ -f "$script" ]; then + local name=$(basename "$script" .sh | sed 's/install-//') + local desc=$(_dfm_get_script_description "$script") + [ -z "$desc" ] && desc="No description available" + scripts+=("${name}:${desc}") + fi + done + + echo ${(F)scripts} +} + +_dfm() +{ local -a commands sections sections=( @@ -11,6 +34,7 @@ _dfm() { 'dotfiles:Dotfiles management commands' 'docs:Documentation commands' 'helpers:Helper utilities' + 'scripts:Installation scripts' 'tests:Test commands' ) @@ -129,6 +153,12 @@ _dfm() { _describe 'helper commands' helpers_cmds ;; + scripts) + local -a script_cmds + script_cmds=("${(@f)$(_dfm_get_available_scripts)}") + _describe 'available scripts' script_cmds + ;; + tests) local -a test_cmds test_cmds=( diff --git a/scripts/create-nvim-keymaps.sh b/scripts/create-nvim-keymaps.sh index 375e0f4..9651616 100755 --- a/scripts/create-nvim-keymaps.sh +++ b/scripts/create-nvim-keymaps.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Create file containing key mappings for Neovim +# @description Create file containing key mappings for Neovim # Usage: ./create-nvim-keymaps.sh # # shellcheck source=shared.sh diff --git a/scripts/create-wezterm-keymaps.sh b/scripts/create-wezterm-keymaps.sh index edb3da2..44c8cfc 100755 --- a/scripts/create-wezterm-keymaps.sh +++ b/scripts/create-wezterm-keymaps.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Create file containing key mappings for wezterm +# @description Create file containing key mappings for wezterm # Usage: ./create-wezterm-keymaps.sh # # shellcheck source=shared.sh diff --git a/scripts/install-cargo-packages.sh b/scripts/install-cargo-packages.sh index e33548d..cb07026 100755 --- a/scripts/install-cargo-packages.sh +++ b/scripts/install-cargo-packages.sh @@ -1,19 +1,18 @@ #!/usr/bin/env bash -# Install cargo/rust packages. +# @description Install cargo/rust packages. # # shellcheck source=shared.sh +source "$HOME/.dotfiles/config/shared.sh" -eval "$HOME/.dotfiles/config/shared.sh" - -msg "Starting to install rust/cargo packages" +msgr run "Starting to install rust/cargo packages" source "$CARGO_HOME/env" # If we have cargo install-update, use it first if command -v cargo-install-update &> /dev/null; then - msg_run "Updating cargo packages with cargo install-update" + msgr run "Updating cargo packages with cargo install-update" cargo install-update -a - msg_done "Done with cargo install-update" + msgr run_done "Done with cargo install-update" fi packages=( @@ -52,8 +51,9 @@ install_packages() # Skip comments if [[ ${pkg:0:1} == "#" ]]; then continue; fi - msg_run "Installing cargo package $pkg" + msgr run "Installing cargo package $pkg" cargo install --jobs $BUILD_JOBS "$pkg" + msgr run_done "Done installing $pkg" echo "" done } @@ -61,14 +61,14 @@ install_packages() # Function to perform additional steps for installed cargo packages post_install_steps() { - msg_run "Now doing the next steps for cargo packages" + msgr run "Now doing the next steps for cargo packages" # use bob to install latest stable nvim if command -v bob &> /dev/null; then bob use stable && x-path-append "$XDG_DATA_HOME/bob/nvim-bin" fi - msg_run "Removing cargo cache" + msgr run "Removing cargo cache" cargo cache --autoclean msg_done "Done removing cargo cache" } diff --git a/scripts/install-cheat-purebashbible.sh b/scripts/install-cheat-purebashbible.sh index c54484f..a8d984e 100755 --- a/scripts/install-cheat-purebashbible.sh +++ b/scripts/install-cheat-purebashbible.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# @description Update pure-bash-bible cheatsheets # shellcheck disable=SC2231,SC2034,SC2181,SC2068 # shellcheck source=shared.sh source "${DOTFILES}/config/shared.sh" diff --git a/scripts/install-composer.sh b/scripts/install-composer.sh index 4982b2a..a4eaf73 100755 --- a/scripts/install-composer.sh +++ b/scripts/install-composer.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install PHP Package Manager Composer +# @description Install PHP Package Manager Composer # # shellcheck source="shared.sh" source "$HOME/.dotfiles/config/shared.sh" diff --git a/scripts/install-fonts.sh b/scripts/install-fonts.sh index b5663a5..21794d2 100755 --- a/scripts/install-fonts.sh +++ b/scripts/install-fonts.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install NerdFonts +# @description Install NerdFonts # # shellcheck source="shared.sh" source "$DOTFILES/config/shared.sh" diff --git a/scripts/install-gh-extensions.sh b/scripts/install-gh-extensions.sh index 953c42e..38f78c7 100755 --- a/scripts/install-gh-extensions.sh +++ b/scripts/install-gh-extensions.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install GitHub CLI extensions +# @description Install GitHub CLI extensions # # shellcheck source="shared.sh" source "${DOTFILES}/config/shared.sh" diff --git a/scripts/install-git-crypt.sh b/scripts/install-git-crypt.sh index 284be58..34d7c4d 100755 --- a/scripts/install-git-crypt.sh +++ b/scripts/install-git-crypt.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash +# @description Install git-crypt # -# Install git-crypt # NOTE: Experimental, wip # # shellcheck source=shared.sh diff --git a/scripts/install-go-packages.sh b/scripts/install-go-packages.sh index a74499d..a02a9db 100755 --- a/scripts/install-go-packages.sh +++ b/scripts/install-go-packages.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install Go packages +# @description Install Go packages # # shellcheck source=shared.sh source "$DOTFILES/config/shared.sh" diff --git a/scripts/set-macos-defaults.sh b/scripts/install-macos-defaults.sh similarity index 99% rename from scripts/set-macos-defaults.sh rename to scripts/install-macos-defaults.sh index 525743c..acaf107 100755 --- a/scripts/set-macos-defaults.sh +++ b/scripts/install-macos-defaults.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Sets macOS Defaults that I like +# @description Sets macOS Defaults that I like # # This script contains large portions from following scripts: # - https://github.com/freekmurze/dotfiles/blob/main/macos/set-defaults.sh diff --git a/scripts/install-npm-packages.sh b/scripts/install-npm-packages.sh index 8d4817d..ce9e797 100755 --- a/scripts/install-npm-packages.sh +++ b/scripts/install-npm-packages.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install npm packages globally. +# @description Install npm packages globally. # # shellcheck source=shared.sh source "$DOTFILES/config/shared.sh" diff --git a/scripts/install-ntfy.sh b/scripts/install-ntfy.sh index 4aa8ab4..e65ce49 100755 --- a/scripts/install-ntfy.sh +++ b/scripts/install-ntfy.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -# -# Install ntfy +# @description Install ntfy # # shellcheck source=shared.sh source "$DOTFILES/config/shared.sh" diff --git a/scripts/install-pip-packages.sh b/scripts/install-pip-packages.sh index 5f4e1c2..b355016 100755 --- a/scripts/install-pip-packages.sh +++ b/scripts/install-pip-packages.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install python/pip packages. +# @description Install python/pip packages. # # shellcheck source=shared.sh source "${DOTFILES}/config/shared.sh" diff --git a/scripts/install-xcode-cli-tools.sh b/scripts/install-xcode-cli-tools.sh index a34e9b5..ada849a 100755 --- a/scripts/install-xcode-cli-tools.sh +++ b/scripts/install-xcode-cli-tools.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install XCode CLI Tools with osascript magic. +# @description Install XCode CLI Tools with osascript magic. # Ismo Vuorinen 2018 # diff --git a/scripts/install-z.sh b/scripts/install-z.sh index 6ff44df..5b14868 100755 --- a/scripts/install-z.sh +++ b/scripts/install-z.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install z +# @description Install z # # shellcheck source=shared.sh source "${DOTFILES}/config/shared.sh"