diff --git a/scripts/core/install b/scripts/core/install index c65b9c52c..d444c9d2e 100755 --- a/scripts/core/install +++ b/scripts/core/install @@ -32,18 +32,18 @@ start_sudo() { } stop_sudo() { - builtin kill "$SUDO_PID" > /dev/null 2>&1 + builtin kill "$SUDO_PID" >/dev/null 2>&1 builtin trap - SIGINT SIGTERM command -p sudo -k } has_sudo() { [[ "${DOTLY_ENV:-PROD}" == "CI" ]] && return - command -p sudo -n -v > /dev/null 2>&1 + command -p sudo -n -v >/dev/null 2>&1 } initilize_sloth_if_necessary() { - if ! git::is_in_repo -C "${SLOTH_PATH:-${DOTLY_PATH:-}}" > /dev/null 2>&1; then + if ! git::is_in_repo -C "${SLOTH_PATH:-${DOTLY_PATH:-}}" >/dev/null 2>&1; then output::answer "Initilizing .Sloth as repository" sloth_update::sloth_repository_set_ready 2>&1 | log::file "Initilizing .Sloth as repository" || true output::empty_line @@ -97,54 +97,54 @@ else link_prefix=/usr/local while [[ $# -gt 0 ]]; do case "${1:-}" in - --backup) - { $interactive_backup || $ignore_backup; } && output::error "Error you can not use \`--backup\` with \`--interactive-backup\` or \`--ignore-backup\`" && exit 4 - backup=true - ;; - --interactive-backup) - { $backup || $ignore_backup; } && output::error "Error you can not use \`--interactive-backup\` with \`--backup\` or \`--ignore-backup\`" && exit 4 - interactive_backup=true - shift - ;; - --ignore-backup) - { $backup || $interactive_backup; } && output::error "Error you can not use \`--ignore-backup\` with \`--backup\` or \`--interactive-backup\`" && exit 4 - ignore_backup=true - shift - ;; - --ignore-symlinks) - ignore_symlinks=true - shift - ;; - --ignore-loader) - ignore_loader=true - shift - ;; - --ignore-restoration) - ignore_restoration=true - shift - ;; - --only-git-init-sloth) - only_git_init_sloth=true - shift - ;; - --ignore-link) - ignore_link=true - shift - ;; - --link-prefix) - [[ -z "${2:-}" ]] && output::error "Wrong usage of \`--link-prefix\` option, it should include a second param with the prefix where to link \`dot\` command." && exit 4 - link_prefix="${2:-}" - shift 2 - ;; - *) - break 2 - ;; + --backup) + { $interactive_backup || $ignore_backup; } && output::error "Error you can not use \`--backup\` with \`--interactive-backup\` or \`--ignore-backup\`" && exit 4 + backup=true + ;; + --interactive-backup) + { $backup || $ignore_backup; } && output::error "Error you can not use \`--interactive-backup\` with \`--backup\` or \`--ignore-backup\`" && exit 4 + interactive_backup=true + shift + ;; + --ignore-backup) + { $backup || $interactive_backup; } && output::error "Error you can not use \`--ignore-backup\` with \`--backup\` or \`--interactive-backup\`" && exit 4 + ignore_backup=true + shift + ;; + --ignore-symlinks) + ignore_symlinks=true + shift + ;; + --ignore-loader) + ignore_loader=true + shift + ;; + --ignore-restoration) + ignore_restoration=true + shift + ;; + --only-git-init-sloth) + only_git_init_sloth=true + shift + ;; + --ignore-link) + ignore_link=true + shift + ;; + --link-prefix) + [[ -z "${2:-}" ]] && output::error "Wrong usage of \`--link-prefix\` option, it should include a second param with the prefix where to link \`dot\` command." && exit 4 + link_prefix="${2:-}" + shift 2 + ;; + *) + break 2 + ;; esac done fi if ${only_git_init_sloth:-false}; then - if platform::command_exists brew && ! brew list gtrabanco/tools/dot > /dev/null 2>&1; then + if platform::command_exists brew && ! brew list gtrabanco/tools/dot >/dev/null 2>&1; then initilize_sloth_if_necessary else output::answer "Skiping init .Sloth installation as repository because you have used a package manager to install it" @@ -256,7 +256,7 @@ export SETUP_ZSH_AS_DEFAULT_SHELL export ZIM_HOME="${DOTFILES_PATH:-}/shell/zsh/.zimfw" export PATH="$HOME/.cargo/bin:$PATH" -if platform::command_exists brew && ! brew list gtrabanco/tools/dot > /dev/null 2>&1; then +if platform::command_exists brew && ! brew list gtrabanco/tools/dot >/dev/null 2>&1; then # Initilize .Sloth only if necessary initilize_sloth_if_necessary fi @@ -274,7 +274,7 @@ output::empty_line # Packages that are necessary but not in CI env if [[ "${DOTLY_ENV:-PROD}" != "CI" ]]; then - script::depends_on docopts fzf python-yq jq cargo-update + script::depends_on docopts fzf yq cargo-update fi if [[ -n "$DOTFILES_PATH" ]]; then @@ -346,7 +346,7 @@ fi zsh_shell_path="$(command -v zsh || true)" output::answer "Trying to setup zsh as the default shell" if $SETUP_ZSH_AS_DEFAULT_SHELL && has_sudo; then - sudo bash -c "echo '$zsh_shell_path' | tee -a /etc/shells" > /dev/null 2>&1 + sudo bash -c "echo '$zsh_shell_path' | tee -a /etc/shells" >/dev/null 2>&1 { sudo chsh -s "$(command -v zsh)" 2>&1 || output::write "Shell could not be changed to zsh" @@ -376,7 +376,7 @@ if [[ "${DOTLY_ENV:-PROD}" != "CI" ]] && platform::command_exists zsh; then output::answer "Installing completions" { - zsh "${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions > /dev/null 2>&1 && + zsh "${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" shell zsh reload_completions >/dev/null 2>&1 && output::solution '✅ ZSH Completions realoaded' } || output::error '❌ Error reloading completions. Execute later \`dot shell zsh reload_completions\`' @@ -384,7 +384,7 @@ if [[ "${DOTLY_ENV:-PROD}" != "CI" ]] && platform::command_exists zsh; then fi if - platform::command_exists brew && ! brew list gtrabanco/tools/dot > /dev/null 2>&1 || + platform::command_exists brew && ! brew list gtrabanco/tools/dot >/dev/null 2>&1 || ! ${ignore_link:-false} then output::answer "Linking dot command for all users in \`${link_prefix}/bin\`" diff --git a/scripts/core/loader b/scripts/core/loader index 9157524b7..252b973cf 100755 --- a/scripts/core/loader +++ b/scripts/core/loader @@ -40,90 +40,90 @@ fi zshrc_load() { case "${1:-both}" in - "zshenv") - echo - echo '###### .Sloth Variables ######' - if [[ -n "${DOTFILES_PATH_VALUE:-}" ]]; then - echo "export DOTFILES_PATH=\"${DOTFILES_PATH_VALUE}\"" - else - echo '# When you have setup your custom dotfiles path modify next value and uncoment it' - echo '# export DOTFILES_PATH="${HOME}/.dotfiles"' - fi - echo "export SLOTH_PATH=\"${SLOTH_PATH_VALUE}\"" - echo "export DOTLY_PATH=\"\${SLOTH_PATH:-}\"" - echo "export ZIM_HOME=\"\${DOTFILES_PATH:-}/shell/zsh/.zimfw\"" - echo '###### End of .Sloth Variables ######' - echo - ;; - "zshrc") - echo - echo '###### .Sloth Loader ######' - echo 'if [[ -f "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh" ]]' - echo 'then' - echo ' #shellcheck disable=SC1091' - echo ' . "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh"' - echo 'else' - echo ' echo "\033[0;31m\033[1mSLOTH Loader could not be found, check \$DOTFILES_PATH & \$SLOTH_PATH variables\033[0m"' - echo 'fi' - echo '###### End of .Sloth loader ######' - echo - ;; - "zimrc") - zimrc_load - ;; - *) - echo 'You need to create or modify two different files' - echo '--------------- BEGIN .zshenv file ---------------' - echo - zshrc_load "zshenv" - echo - echo '--------------- END .zshenv file ---------------' - echo - echo - echo - echo '--------------- BEGIN .zshrc file ---------------' - echo - zshrc_load "zshrc" - echo - echo '--------------- END .zshrc file ---------------' - echo - ;; + "zshenv") + echo + echo '###### .Sloth Variables ######' + if [[ -n "${DOTFILES_PATH_VALUE:-}" ]]; then + echo "export DOTFILES_PATH=\"${DOTFILES_PATH_VALUE}\"" + else + echo '# When you have setup your custom dotfiles path modify next value and uncoment it' + echo '# export DOTFILES_PATH="${HOME}/.dotfiles"' + fi + echo "export SLOTH_PATH=\"${SLOTH_PATH_VALUE}\"" + echo "export DOTLY_PATH=\"\${SLOTH_PATH:-}\"" + echo "export ZIM_HOME=\"\${DOTFILES_PATH:-}/shell/zsh/.zimfw\"" + echo '###### End of .Sloth Variables ######' + echo + ;; + "zshrc") + echo + echo '###### .Sloth Loader ######' + echo 'if [[ -f "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh" ]]' + echo 'then' + echo ' #shellcheck disable=SC1091' + echo ' . "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh"' + echo 'else' + echo ' echo "\033[0;31m\033[1mSLOTH Loader could not be found, check \$DOTFILES_PATH & \$SLOTH_PATH variables\033[0m"' + echo 'fi' + echo '###### End of .Sloth loader ######' + echo + ;; + "zimrc") + zimrc_load + ;; + *) + echo 'You need to create or modify two different files' + echo '--------------- BEGIN .zshenv file ---------------' + echo + zshrc_load "zshenv" + echo + echo '--------------- END .zshenv file ---------------' + echo + echo + echo + echo '--------------- BEGIN .zshrc file ---------------' + echo + zshrc_load "zshrc" + echo + echo '--------------- END .zshrc file ---------------' + echo + ;; esac } bashrc_load() { case "${1:-both}" in - "vars") - echo - echo '###### .Sloth Variables ######' - if [[ -n "${DOTFILES_PATH_VALUE:-}" ]]; then - echo "export DOTFILES_PATH=\"${DOTFILES_PATH_VALUE}\"" - else - echo '# When you have setup your custom dotfiles path modify next value and uncoment it' - echo '# export DOTFILES_PATH="${HOME}/.dotfiles"' - fi - echo "export SLOTH_PATH=\"${SLOTH_PATH_VALUE}\"" - echo "export DOTLY_PATH=\"\${SLOTH_PATH:-}\"" - echo '###### End of .Sloth Variables ######' - echo - ;; - "loader") - echo - echo '###### .Sloth Loader ######' - echo 'if [[ -f "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh" ]]' - echo 'then' - echo ' #shellcheck disable=SC1091' - echo ' . "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh"' - echo 'else' - echo ' echo "\033[0;31m\033[1mSLOTH Loader could not be found, check \$DOTFILES_PATH & \$SLOTH_PATH variables\033[0m"' - echo 'fi' - echo '###### End of .Sloth loader ######' - echo - ;; - *) - bashrc_load "vars" - bashrc_load "loader" - ;; + "vars") + echo + echo '###### .Sloth Variables ######' + if [[ -n "${DOTFILES_PATH_VALUE:-}" ]]; then + echo "export DOTFILES_PATH=\"${DOTFILES_PATH_VALUE}\"" + else + echo '# When you have setup your custom dotfiles path modify next value and uncoment it' + echo '# export DOTFILES_PATH="${HOME}/.dotfiles"' + fi + echo "export SLOTH_PATH=\"${SLOTH_PATH_VALUE}\"" + echo "export DOTLY_PATH=\"\${SLOTH_PATH:-}\"" + echo '###### End of .Sloth Variables ######' + echo + ;; + "loader") + echo + echo '###### .Sloth Loader ######' + echo 'if [[ -f "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh" ]]' + echo 'then' + echo ' #shellcheck disable=SC1091' + echo ' . "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/init-sloth.sh"' + echo 'else' + echo ' echo "\033[0;31m\033[1mSLOTH Loader could not be found, check \$DOTFILES_PATH & \$SLOTH_PATH variables\033[0m"' + echo 'fi' + echo '###### End of .Sloth loader ######' + echo + ;; + *) + bashrc_load "vars" + bashrc_load "loader" + ;; esac } @@ -133,7 +133,7 @@ zimrc_load() { return fi - cat << EOF + cat <> "${HOME}/.bash_profile" - echo '. "${HOME}/.bashrc"' >> "${HOME}/.bash_profile" + echo '#shellcheck disable=SC1091' >>"${HOME}/.bash_profile" + echo '. "${HOME}/.bashrc"' >>"${HOME}/.bash_profile" fi if check_has_loader "$rcfile" && check_file_has_var_defined "$rcfile" "DOTFILES_PATH" && check_file_has_var_defined "$rcfile" "SLOTH_PATH"; then @@ -242,7 +242,7 @@ setup_zsh() { { ! grep -q '\. .*/login_init.zsh.* -q &!$' "${HOME}/.zlogin" || ! grep -q '. "${ZIM_HOME}/login_init.zsh" -q &!' "${HOME}/.zlogin"; } then _log "Appending login_init.zsh in \`${HOME}/.zlogin\`" - echo '. "${ZIM_HOME}/login_init.zsh" -q &!' >> "${HOME}/.zlogin" + echo '. "${ZIM_HOME}/login_init.zsh" -q &!' >>"${HOME}/.zlogin" fi if [[ ! -f "${HOME}/.zimrc" ]]; then @@ -310,95 +310,95 @@ else action="$1" while [[ $# -gt 0 ]]; do case "${1:-}" in - bashrc) - $zshrc && output::error "\`bashrc\` subcommand is not compatible with \`zshrc\` subcommand" && exit 1 - bashrc=true - action="bashrc" - shift - ;; - zsh | zshrc) - $bashrc && output::error "\`zshrc\` subcommand is not compatible with \`bashrc\` subcommand" && exit 1 - zshrc=true - action="zshrc" - shift - ;; - shellenv) - #shellcheck disable=SC2034 - shellenv=true - action="shellenv" - shift - ;; - --modify) - modify=true - shift - ;; - *) - ! $zshrc && - ! $bashrc && - ! $modify && - output::error "\`--modify\` is mandatory option when no \`bashrc\` or \`zshrc\` subcommand are used" && - exit 1 - - break 2 - ;; + bashrc) + $zshrc && output::error "\`bashrc\` subcommand is not compatible with \`zshrc\` subcommand" && exit 1 + bashrc=true + action="bashrc" + shift + ;; + zsh | zshrc) + $bashrc && output::error "\`zshrc\` subcommand is not compatible with \`bashrc\` subcommand" && exit 1 + zshrc=true + action="zshrc" + shift + ;; + shellenv) + #shellcheck disable=SC2034 + shellenv=true + action="shellenv" + shift + ;; + --modify) + modify=true + shift + ;; + *) + ! $zshrc && + ! $bashrc && + ! $modify && + output::error "\`--modify\` is mandatory option when no \`bashrc\` or \`zshrc\` subcommand are used" && + exit 1 + + break 2 + ;; esac done fi case "${action:-${1:-}}" in - # Any subcommand should be here - bashrc) - if ${modify:-false}; then - if setup_bashrc 2>&1 | log::file "Setup .Sloth in .bashrc file"; then - output::answer "🏁 Restart your \`bash\` shell to have .Sloth loaded" - else - output::error "🚨 Something went modifing your \`.bashrc\` file" - fi +# Any subcommand should be here +bashrc) + if ${modify:-false}; then + if setup_bashrc 2>&1 | log::file "Setup .Sloth in .bashrc file"; then + output::answer "🏁 Restart your \`bash\` shell to have .Sloth loaded" else - bashrc_load + output::error "🚨 Something went modifing your \`.bashrc\` file" fi - ;; - zshrc) - if ${modify:-false}; then - if setup_zsh 2>&1 | log::file "Setup .Sloth in .zshenv & .zshrc files"; then - output::answer "🏁 Restart your \`zsh\` shell to have .Sloth loaded" - else - output::error "🚨 Something went wrong modifing your .zshrc & .zshenv file" - fi + else + bashrc_load + fi + ;; +zshrc) + if ${modify:-false}; then + if setup_zsh 2>&1 | log::file "Setup .Sloth in .zshenv & .zshrc files"; then + output::answer "🏁 Restart your \`zsh\` shell to have .Sloth loaded" else - zshrc_load + output::error "🚨 Something went wrong modifing your .zshrc & .zshenv file" fi - ;; - shellenv) - [[ ! -f "${HOME}/.zimrc" ]] && zshrc_load zimrc | tee "${HOME}/.zimrc" > /dev/null 2>&1 - - case "${SHELL##*/}" in - bash) - bashrc_load - ;; - *) - zshrc_load zshenv - output::empty_line - zshrc_load zshrc - ;; - esac - exit + else + zshrc_load + fi + ;; +shellenv) + [[ ! -f "${HOME}/.zimrc" ]] && zshrc_load zimrc | tee "${HOME}/.zimrc" >/dev/null 2>&1 + + case "${SHELL##*/}" in + bash) + bashrc_load ;; *) - if ${modify:-false}; then - if setup_bashrc 2>&1 | log::file "Setup .Sloth in .bashrc file"; then - output::answer "🏁 Restart your \`bash\` shell to have .Sloth loaded" - else - output::error "🚨 Something went wrong modifing your \`.bashrc\` file" - fi - - if setup_zsh 2>&1 | log::file "Setup .Sloth in .zshenv & .zshrc files"; then - output::answer "🏁 Restart your \`zsh\` shell to have .Sloth loaded" - else - output::error "🚨 Something went wrong modifing your .zshrc & .zshenv file" - fi + zshrc_load zshenv + output::empty_line + zshrc_load zshrc + ;; + esac + exit + ;; +*) + if ${modify:-false}; then + if setup_bashrc 2>&1 | log::file "Setup .Sloth in .bashrc file"; then + output::answer "🏁 Restart your \`bash\` shell to have .Sloth loaded" else - output::error "Wrong parameters" + output::error "🚨 Something went wrong modifing your \`.bashrc\` file" fi - ;; + + if setup_zsh 2>&1 | log::file "Setup .Sloth in .zshenv & .zshrc files"; then + output::answer "🏁 Restart your \`zsh\` shell to have .Sloth loaded" + else + output::error "🚨 Something went wrong modifing your .zshrc & .zshenv file" + fi + else + output::error "Wrong parameters" + fi + ;; esac diff --git a/scripts/core/short_pwd b/scripts/core/short_pwd index e82d5cc48..433cbdfa2 100755 --- a/scripts/core/short_pwd +++ b/scripts/core/short_pwd @@ -1,21 +1,12 @@ #!/usr/bin/env zsh -set -euo pipefail - -##### Start of Homebrew Installation Patch ##### -# export HOMEBREW_SLOTH=true -# export SLOTH_PATH="HOMEBREW_PREFIX/opt/dot" -##### End of Hombrew Installation Patch ##### - -. "${SLOTH_PATH:-${DOTLY_PATH:-}}/scripts/core/src/_main.sh" - ##? Short the current $PWD ##? ##? Usage: ##? short_pwd #? v1.0.0 -if [[ $(pwd) == "$HOME" ]]; then +if [[ "$PWD" == "$HOME" ]]; then echo "~" else echo ${${${:-/${(j:/:)${(M)${(s:/:)${(D)PWD:h}}#(|.)[^.]}}/${PWD:t}}//\/~/\~}/\/\//\/} diff --git a/scripts/core/src/github.sh b/scripts/core/src/github.sh index dd8da0e50..135c4c4bc 100644 --- a/scripts/core/src/github.sh +++ b/scripts/core/src/github.sh @@ -245,7 +245,7 @@ github::curl() { github::get_latest_sloth_tag() { github::check_jq - github::curl "$(github::get_api_url "$GITHUB_SLOTH_REPOSITORY" "tags")" | jq -r '.[0].name' | uniq + github::curl "$(github::get_api_url "$GITHUB_SLOTH_REPOSITORY" "tags")" | yq -p=json -r '.[0].name' | uniq } #; @@ -265,24 +265,24 @@ github::get_remote_file_path_json() { if [[ $1 == *"api.github.com/"* ]]; then url="$1" else - default_branch="$(github::get_api_url "$1" | github::curl | jq -r '.default_branch')" + default_branch="$(github::get_api_url "$1" | github::curl | yq -p=json -r '.default_branch')" if [[ -z "$default_branch" ]]; then echoerr "No default branch found for repository '$1'" return 1 fi - url="$(github::get_api_url --branch "${default_branch}" "$1" | github::curl | jq -r '.commit.commit.tree.url' 2> /dev/null)" + url="$(github::get_api_url --branch "${default_branch}" "$1" | github::curl | yq -p=json -r '.commit.commit.tree.url' 2> /dev/null)" fi shift [[ -z "${url:-}" ]] && return 1 readarray -t file_paths < <(str::join "/" "$@" | tr "/" "\n") - json="$(github::curl "$url" | jq --arg file_path "${file_paths[0]}" '.tree[] | select(.path == $file_path)' 2> /dev/null)" + json="$(github::curl "$url" | yq -p=json --arg file_path "${file_paths[0]}" '.tree[] | select(.path == $file_path)' 2> /dev/null)" if [[ -n "$json" ]] && [[ ${#file_paths[@]} -gt 1 ]]; then - github::get_remote_file_path_json "$(echo "$json" | jq -r '.url')" "$(str::join / "${file_paths[@]:1}")" && return + github::get_remote_file_path_json "$(echo "$json" | yq -p=json -r '.url')" "$(str::join / "${file_paths[@]:1}")" && return elif [[ -n "$json" ]]; then printf "%s" "$json" return diff --git a/scripts/core/src/json.sh b/scripts/core/src/json.sh index 555fb4111..58c1f49e2 100644 --- a/scripts/core/src/json.sh +++ b/scripts/core/src/json.sh @@ -10,8 +10,8 @@ json::to_yaml() { json::is_valid() { if [[ -t 0 ]]; then - [[ -n "${1:-}" && -f "$1" ]] && jq -e '.' < "$1" > /dev/null 2>&1 + [[ -n "${1:-}" && -f "$1" ]] && yq -p=json -e '.' < "$1" > /dev/null 2>&1 else - jq -e '.' < /dev/stdin > /dev/null 2>&1 + yq -p=json -e '.' < /dev/stdin > /dev/null 2>&1 fi } diff --git a/scripts/core/src/script.sh b/scripts/core/src/script.sh index fe1b4d048..1f9765160 100755 --- a/scripts/core/src/script.sh +++ b/scripts/core/src/script.sh @@ -7,6 +7,7 @@ command_or_package_exists() { script::depends_on() { utils::curry command_not_exists utils::not command_or_package_exists + non_existing_commands=$(coll::filter command_not_exists "${@:1:1}") for non_existing_command in $non_existing_commands; do diff --git a/scripts/package/add b/scripts/package/add index 06f0e8b48..69109ad6d 100755 --- a/scripts/package/add +++ b/scripts/package/add @@ -1,6 +1,7 @@ #!/usr/bin/env bash # FORCE_LEGACY_EXECUTION +echo "Received args to add package $*" >>~/dotly.log #shellcheck disable=SC1091 . "${SLOTH_PATH:-${DOTLY_PATH:-}}/scripts/core/src/_main.sh" @@ -27,32 +28,32 @@ packages_names=() force=false while [[ $# -gt 0 ]]; do case "${1:-}" in - --skipe-recipe | -s) - skip_recipe=true - shift - ;; - --pkgmgr) - package_manager="$2" - shift 2 - ;; - --force | -f) - force=true - shift - ;; - --help | -h) - echo "help" - docs::parse_docopt "${BASH_SOURCE[$((${#BASH_SOURCE[*]} - 1))]}" - exit - ;; - --version | -v) - echo "version" - docs::parse_version "${BASH_SOURCE[$((${#BASH_SOURCE[*]} - 1))]}" - exit - ;; - *) - packages_names+=("$1") - shift - ;; + --skipe-recipe | -s) + skip_recipe=true + shift + ;; + --pkgmgr) + package_manager="$2" + shift 2 + ;; + --force | -f) + force=true + shift + ;; + --help | -h) + echo "help" + docs::parse_docopt "${BASH_SOURCE[$((${#BASH_SOURCE[*]} - 1))]}" + exit + ;; + --version | -v) + echo "version" + docs::parse_version "${BASH_SOURCE[$((${#BASH_SOURCE[*]} - 1))]}" + exit + ;; + *) + packages_names+=("$1") + shift + ;; esac done diff --git a/scripts/package/src/package_managers/composer.sh b/scripts/package/src/package_managers/composer.sh index 17ec25cbb..d5e50cc55 100644 --- a/scripts/package/src/package_managers/composer.sh +++ b/scripts/package/src/package_managers/composer.sh @@ -16,10 +16,10 @@ composer::update_all() { if [ -f "$HOME/.composer/composer.json" ]; then outdated=$(composer global outdated --direct -f json --no-ansi) - total_outdated=$(echo "$outdated" | jq '.installed' | jq length) + total_outdated=$(echo "$outdated" | yq -p=json '.installed' | yq -p=json length) if [ 0 -ne "$total_outdated" ]; then - echo "$outdated" | jq -cr '.installed | .[]' | while IFS= read -r dependency; do + echo "$outdated" | yq -p=json -cr '.installed | .[]' | while IFS= read -r dependency; do composer::update "$dependency" done else @@ -32,10 +32,10 @@ composer::update_all() { } composer::update() { - name=$(echo "$1" | jq -r '.name') - current_version=$(echo "$1" | jq -r '.version') - new_version=$(echo "$1" | jq -r '.latest') - summary=$(echo "$1" | jq -r '.description') + name=$(echo "$1" | yq -p=json -r '.name') + current_version=$(echo "$1" | yq -p=json -r '.version') + new_version=$(echo "$1" | yq -p=json -r '.latest') + summary=$(echo "$1" | yq -p=json -r '.description') url="https://packagist.org/packages/$name" output::write "🐘 $name" diff --git a/scripts/package/src/package_managers/pipx.sh b/scripts/package/src/package_managers/pipx.sh index 6deac1535..251c5450f 100644 --- a/scripts/package/src/package_managers/pipx.sh +++ b/scripts/package/src/package_managers/pipx.sh @@ -97,7 +97,7 @@ pipx::dump() { if package::common_dump_check pipx "$PIPX_DUMP_FILE_PATH"; then script::depends_on jq - readarray -t packages < <(pipx::pipx list --json | jq -re 'if has("venvs") then .venvs | keys | .[] else "" end' 2> /dev/null) + readarray -t packages < <(pipx::pipx list --json | yq -p=json -re 'if has("venvs") then .venvs | keys | .[] else "" end' 2> /dev/null) printf "%s\n" "${packages[@]}" | tee "$PIPX_DUMP_FILE_PATH" | log::file "Exporting $pipx_title packages" return 0 diff --git a/scripts/package/src/recipes/zimfw.sh b/scripts/package/src/recipes/zimfw.sh index 34628c23b..22241b0f6 100644 --- a/scripts/package/src/recipes/zimfw.sh +++ b/scripts/package/src/recipes/zimfw.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash -ZIMFW_GIT_REPOSITORY_URL="git@github.com:zimfw/zimfw.git" +# ZIMFW_GIT_REPOSITORY_URL="git@github.com:zimfw/zimfw.git" +ZIMFW_GIT_REPOSITORY_URL="https://github.com/zimfw/zimfw.git" zimfw::fix_zim_home() { if [[ "$ZIM_HOME" == *"modules/zimfw"* ]]; then diff --git a/shell/init-sloth.sh b/shell/init-sloth.sh index 9b81d7d16..1f5d60c13 100644 --- a/shell/init-sloth.sh +++ b/shell/init-sloth.sh @@ -162,9 +162,9 @@ if [[ -z "${BREW_BIN:-}" || ! -x "$BREW_BIN" ]]; then elif [[ -x "/usr/local/bin/brew" ]]; then BREW_BIN="/usr/local/bin/brew" HOMEBREW_PREFIX="/usr/local" - elif command -v brew > /dev/null 2>&1; then + elif command -v brew >/dev/null 2>&1; then BREW_BIN="$(command -v brew)" - elif command -vp brew > /dev/null 2>&1; then + elif command -vp brew >/dev/null 2>&1; then BREW_BIN="$(command -vp brew)" fi fi @@ -224,16 +224,16 @@ fi # Conditional paths [ -d "${HOME}/.cargo/bin" ] && path+=("${HOME}/.cargo/bin") [ -d "${JAVA_HOME:-}" ] && path+=("${JAVA_HOME}/bin") -if command -v gem > /dev/null 2> /dev/null || command -vp gem > /dev/null 2>&1; then +if command -v gem >/dev/null 2>/dev/null || command -vp gem >/dev/null 2>&1; then gem_bin="$(command -v gem || command -vp gem)" - gem_paths="$("$gem_bin" env gempath 2> /dev/null)" + gem_paths="$("$gem_bin" env gempath 2>/dev/null)" #shellcheck disable=SC2207 [[ -n "$gem_paths" ]] && path+=($(echo "$gem_paths" | command -p tr ':' "\n" | command -p xargs -I _ echo _"/bin")) fi [ -d "${GOHOME:-}" ] && path+=("${GOHOME}/bin") [ -d "${HOME}/.deno/bin" ] && path+=("${HOME}/.deno/bin") -if command -v python3 > /dev/null 2>&1; then +if command -v python3 >/dev/null 2>&1; then python_path="$(command python3 -c 'import site; print(site.USER_BASE)' | command -p xargs)/bin" [[ -d "$python_path" ]] && path+=("$(command python3 -c 'import site; print(site.USER_BASE)' | command -p xargs)/bin") fi @@ -252,7 +252,6 @@ path+=( path+=($(command -p getconf PATH | command -p tr ':' '\n')) { [[ "${DOTLY_ENV:-PROD}" == "CI" ]] && echo ".Sloth initializer: End PATHs"; } || true ###### END OF PATHS ###### - ###### Load dotly core for your current BASH ###### if [[ -n "$SLOTH_SHELL" && -r "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/${SLOTH_SHELL}/init.sh" ]]; then . "${SLOTH_PATH:-${DOTLY_PATH:-}}/shell/${SLOTH_SHELL}/init.sh" || echo ".Sloth initializer: SHELL ($SLOTH_SHELL) initializer failed" @@ -300,7 +299,7 @@ if -d "$init_scripts_path" ]] then - for init_script in $(command -p find "${DOTFILES_PATH}/shell/init.scripts-enabled" -mindepth 1 -maxdepth 1 -not -iname ".*" -not -type d -print0 2> /dev/null | command -p xargs -0 -I _ command realpath --quiet --logical _); do + for init_script in $(command -p find "${DOTFILES_PATH}/shell/init.scripts-enabled" -mindepth 1 -maxdepth 1 -not -iname ".*" -not -type d -print0 2>/dev/null | command -p xargs -0 -I _ command realpath --quiet --logical _); do [[ -z "$init_script" ]] && continue { [[ -r "$init_script" ]] && . "$init_script"; } || echo -e "\033[0;31m${init_script} could not be loaded\033[0m" diff --git a/shell/zsh/init.sh b/shell/zsh/init.sh index 3a124c2a9..18ae3b45b 100755 --- a/shell/zsh/init.sh +++ b/shell/zsh/init.sh @@ -28,7 +28,6 @@ setopt +o nomatch # Start zim if ! ${SLOTH_DISABLE_ZIMFW:-false} && [[ -n "${ZIM_HOME:-}" && -d "${ZIM_HOME:-}" && -r "${ZIM_HOME}/init.zsh" ]]; then [[ -z "${ZSH_HIGHLIGHT_HIGHLIGHTERS:-}" ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) - #shellcheck disable=SC1091 . "${ZIM_HOME}/init.zsh" || echo "Error loading ZimFW" { [[ "${DOTLY_ENV:-PROD}" == "CI" ]] && echo "Loaded ZimFW"; } || true @@ -59,8 +58,8 @@ if [[ -n "${HOMEBREW_PREFIX:-}" ]]; then ) fi -autoload -Uz promptinit && promptinit -prompt "${SLOTH_ZSH_THEME:-${SLOTH_THEME:-${DOTLY_THEME:-codely}}}" +# autoload -Uz promptinit && promptinit +# prompt "${SLOTH_ZSH_THEME:-${SLOTH_THEME:-${DOTLY_THEME:-codely}}}" if [[ @@ -76,4 +75,4 @@ if [[ -r "${DOTFILES_PATH}/shell/zsh/key-bindings.zsh" ]]; then . "${DOTFILES_PATH}/shell/zsh/key-bindings.zsh" fi -unset tmp_fpath +unset tmp_fpath \ No newline at end of file diff --git a/shell/zsh/themes/prompt_codely_setup b/shell/zsh/themes/prompt_codely_setup index 2571a975e..521319714 100644 --- a/shell/zsh/themes/prompt_codely_setup +++ b/shell/zsh/themes/prompt_codely_setup @@ -34,7 +34,7 @@ fi prompt_codely_pwd() { case "$CODELY_THEME_PWD_MODE" in - short) local -r prompt_dir=$("${SLOTH_PATH:-${DOTLY_PATH:-}}/bin/dot" core short_pwd) ;; + short) local -r prompt_dir=$("${SLOTH_PATH:-${DOTLY_PATH:-}}/scripts/core/short_pwd") ;; full) local -r prompt_dir="$PWD" ;; home_relative) local -r prompt_dir=$(print -rD "$PWD") ;; esac @@ -50,12 +50,6 @@ prompt_codely_precmd() { (( ${+functions[git-info]} )) && git-info } -prompt_dotly_autoupdate() { - if [ -f "$DOTFILES_PATH/.sloth_update_available" ]; then - print -n "📥 | " - fi -} - prompt_codely_setup() { local prompt_codely_status @@ -72,9 +66,9 @@ prompt_codely_setup() { zstyle ':zim:git-info:keys' format "prompt" " %F{cyan}%b%c %C%D" if [ "$CODELY_THEME_MINIMAL" = true ]; then - PS1="\$(prompt_dotly_autoupdate)${prompt_codely_status} \$(prompt_codely_pwd) " + PS1="${prompt_codely_status} \$(prompt_codely_pwd) " else - PS1="\$(prompt_dotly_autoupdate)${prompt_codely_status} \$(prompt_codely_pwd)\$(prompt_codely_git)%f " + PS1="${prompt_codely_status} \$(prompt_codely_pwd)\$(prompt_codely_git)%f " fi if [ "$CODELY_THEME_PROMPT_IN_NEW_LINE" = true ]; then