From ad8d135d925428f25553c751ca66636e7934f178 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Tue, 18 May 2021 16:20:27 +0200 Subject: [PATCH 01/15] Added cargo export/import --- scripts/package/dump | 8 ++++++++ scripts/package/import | 11 +++++++++++ scripts/package/src/dump.sh | 24 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/scripts/package/dump b/scripts/package/dump index 10ac2dd1e..29d504494 100755 --- a/scripts/package/dump +++ b/scripts/package/dump @@ -26,6 +26,7 @@ fi HOMEBREW_DUMP_FILE_PATH="$DOTFILES_PATH/os/mac/brew/${HOSTNAME}" APT_DUMP_FILE_PATH="$DOTFILES_PATH/os/linux/apt/${HOSTNAME}.txt" SNAP_DUMP_FILE_PATH="$DOTFILES_PATH/os/linux/snap/${HOSTNAME}.txt" +CARGO_DUMP_FILE_PATH="$DOTFILES_PATH/langs/rust/cargo/${HOSTNAME}.txt" PYTHON_DUMP_FILE_PATH="$DOTFILES_PATH/langs/python/${HOSTNAME}.txt" NPM_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/npm/${HOSTNAME}.txt" VOLTA_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/volta/${HOSTNAME}.txt" @@ -52,6 +53,13 @@ VOLTA_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/volta/${HOSTNAME}.txt" output::empty_line } || package::clarification "${snap_title:-SNAP}" +{ + platform::command_exists cargo &&\ + package::cargo_dump "$CARGO_DUMP_FILE_PATH" &&\ + output::answer "${cargo_title:-Cargo} apps dumped on $CARGO_DUMP_FILE_PATH" &&\ + output::empty_line +} || package::clarification "${cargo_title:-Cargo}" + { platform::command_exists pip3 && \ package::python_dump "$PYTHON_DUMP_FILE_PATH" && \ diff --git a/scripts/package/import b/scripts/package/import index ad45ed1ef..03a2a040b 100755 --- a/scripts/package/import +++ b/scripts/package/import @@ -28,6 +28,7 @@ docs::parse "$@" BREW_PATH="${BREW_PATH:-$DOTFILES_PATH/os/mac/brew}" APT_PATH="${APT_PATH:-$DOTFILES_PATH/os/linux/apt}" SNAP_PATH="${SNAP_PATH:-$DOTFILES_PATH/os/linux/snap}" +CARGO_PATH="${CARGO_PATH:-$DOTFILES_PATH/langs/rust/cargo/}" PYTHON_PATH="${PYTHON_PATH:-$DOTFILES_PATH/langs/python}" NPM_PATH="${NPM_PATH:-$DOTFILES_PATH/langs/js/npm}" VOLTA_PATH="${VOLTA_PATH:-$DOTFILES_PATH/langs/js/volta}" @@ -36,6 +37,7 @@ VOLTA_PATH="${VOLTA_PATH:-$DOTFILES_PATH/langs/js/volta}" HOMEBREW_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$BREW_PATH")" APT_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$APT_PATH")" SNAP_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$SNAP_PATH")" +CARGO_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$CARGO_PATH")" PYTHON_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$PYTHON_PATH")" NPM_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$NPM_PATH")" VOLTA_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$VOLTA_PATH")" @@ -44,6 +46,7 @@ if ! ${never_prompt:-false}; then platform::command_exists brew && [[ -z "$HOMEBREW_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$BREW_PATH" "Select ${brew_title:-Brew} file to import" "HOMEBREW_DUMP_FILE_PATH" platform::command_exists apt && [[ -z "$APT_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$APT_PATH" "Select ${apt_title:-APT} file of modules to import" "APT_DUMP_FILE_PATH" platform::command_exists snap && [[ -z "$SNAP_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$SNAP_PATH" "Select ${snap_title:-SNAP} file of modules to import" "SNAP_DUMP_FILE_PATH" + platform::command_exists cargo && [[ -z "$CARGO_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$CARGO_PATH" "Select ${cargo_title:-Cargo} file to import" "CARGO_DUMP_FILE_PATH" platform::command_exists pip3 && [[ -z "$PYTHON_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$PYTHON_PATH" "Select ${pip_title:-Python} requirements file to import" "PYTHON_DUMP_FILE_PATH" platform::command_exists volta && [[ -z "$VOLTA_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$VOLTA_PATH" "Select ${volta_title:-volta} file to import" "VOLTA_DUMP_FILE_PATH" platform::command_exists npm && [[ -z "$NPM_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$NPM_PATH" "Select ${npm_title:-NPM} file of modules to import" "NPM_DUMP_FILE_PATH" @@ -75,6 +78,14 @@ output::write "🎩 Let's import your packages (this could take a while)" && out } ||\ output::answer "Ignoring SNAP" +{ + platform::command_exists cargo &&\ + output::header "Importing Cargo apps from $CARGO_DUMP_FILE_PATH" &&\ + package::cargo_import &&\ + output::empty_line +} ||\ + output::answer "Ignoring Cargo" + { platform::command_exists pip3 && [[ -n "$PYTHON_DUMP_FILE_PATH" ]] &&\ output::empty_line &&\ diff --git a/scripts/package/src/dump.sh b/scripts/package/src/dump.sh index a254b0be2..51aa7611c 100644 --- a/scripts/package/src/dump.sh +++ b/scripts/package/src/dump.sh @@ -218,3 +218,27 @@ package::volta_import() { return 1 } + +package::cargo_dump() { + CARGO_DUMP_FILE_PATH="${1:-$CARGO_DUMP_FILE_PATH}" + + if package::common_dump_check cargo "$CARGO_DUMP_FILE_PATH"; then + cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' >|"$CARGO_DUMP_FILE_PATH" + + return 0 + fi + + return 1 +} + +package::cargo_import() { + CARGO_DUMP_FILE_PATH="${1:-$VOLTA_DUMP_FILE_PATH}" + + if package::common_import_check cargo "$CARGO_DUMP_FILE_PATH"; then + xargs -I_ cargo install < "$CARGO_DUMP_FILE_PATH" + + return 0 + fi + + return 1 +} From 0e01e289a93aae704ccc1b03e602218b6a97e29d Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Mon, 24 May 2021 15:30:16 +0200 Subject: [PATCH 02/15] Fix(dump.sh): Apply patch to fix wrong importing file - Fixed wrong importing file when computer hostname was similar to another one - Fixed errors in messages --- scripts/package/src/dump.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/package/src/dump.sh b/scripts/package/src/dump.sh index 51aa7611c..eda2225e5 100644 --- a/scripts/package/src/dump.sh +++ b/scripts/package/src/dump.sh @@ -16,7 +16,7 @@ package::exists_dump_current_machine_file() { local FILES_PATH FILES_PATH="$(realpath -sm "$1")" - ls -1 -d "$FILES_PATH"/* 2>/dev/null | grep -v ".lock.json$" | grep "$(hostname -s)" + ls -1 -d "$FILES_PATH"/* 2>/dev/null | grep -v ".lock.json$" | grep "^$(hostname -s)$" } package::preview() { @@ -77,7 +77,7 @@ package::brew_dump() { if package::common_dump_check brew "$HOMEBREW_DUMP_FILE_PATH"; then output::write "🚀 Starting Brew dump to '$HOMEBREW_DUMP_FILE_PATH'" - brew bundle dump --file="$HOMEBREW_DUMP_FILE_PATH" --force | log::file "Exporting $brew_title packages list" + brew bundle dump --file="$HOMEBREW_DUMP_FILE_PATH" --force | log::file "Exporting $brew_title packages" brew bundle --file="$HOMEBREW_DUMP_FILE_PATH" --force cleanup || true return 0 @@ -91,7 +91,7 @@ package::brew_import() { if package::common_import_check brew "$HOMEBREW_DUMP_FILE_PATH"; then output::write "🚀 Importing 🍺 brew from '$HOMEBREW_DUMP_FILE_PATH'" - brew bundle install --file="$HOMEBREW_DUMP_FILE_PATH" | log::file "Importing $brew_title packages list" + brew bundle install --file="$HOMEBREW_DUMP_FILE_PATH" | log::file "Importing $brew_title packages" return 0 fi @@ -104,7 +104,7 @@ package::apt_dump() { if package::common_dump_check apt "$APT_DUMP_FILE_PATH"; then output::write "🚀 Starting APT dump to '$APT_DUMP_FILE_PATH'" - apt-mark showmanual >|"$APT_DUMP_FILE_PATH" | log::file "Exporting $apt_title packages list" + apt-mark showmanual >|"$APT_DUMP_FILE_PATH" | log::file "Exporting $apt_title packages" return 0 fi @@ -117,7 +117,7 @@ package::apt_import() { if package::common_import_check apt "$APT_DUMP_FILE_PATH"; then output::write "🚀 Importing APT from '$HOMEBREW_DUMP_FILE_PATH'" - xargs sudo apt-get install -y <"$APT_DUMP_FILE_PATH" | log::file "Importing $apt_title packages list" + xargs sudo apt-get install -y <"$APT_DUMP_FILE_PATH" | log::file "Importing $apt_title packages" fi } @@ -126,7 +126,7 @@ package::snap_dump() { if package::common_dump_check snap "$SNAP_DUMP_FILE_PATH"; then output::write "🚀 Starting SNAP dump to '$SNAP_DUMP_FILE_PATH'" - snap list | tail -n +2 | awk '{ print $1 }' >|"$SNAP_DUMP_FILE_PATH" | log::file "Exporting $snap_title containers list" + snap list | tail -n +2 | awk '{ print $1 }' >|"$SNAP_DUMP_FILE_PATH" | log::file "Exporting $snap_title containers" return 0 fi @@ -139,7 +139,7 @@ package::snap_import() { if package::common_import_check snap "$SNAP_DUMP_FILE_PATH"; then output::write "🚀 Importing SNAP from '$HOMEBREW_DUMP_FILE_PATH'" - xargs -I_ sudo snap install "_" <"$SNAP_DUMP_FILE_PATH" | log::file "Importing $snap_title containers list" + xargs -I_ sudo snap install "_" <"$SNAP_DUMP_FILE_PATH" | log::file "Importing $snap_title containers" fi } @@ -148,7 +148,7 @@ package::python_dump() { if package::common_dump_check pip3 "$PYTHON_DUMP_FILE_PATH"; then output::write "🚀 Starting Python dump to '$PYTHON_DUMP_FILE_PATH'" - pip3 freeze >"$PYTHON_DUMP_FILE_PATH" | log::file "Exporting $pip_title packages list" + pip3 freeze >"$PYTHON_DUMP_FILE_PATH" | log::file "Exporting $pip_title packages" return 0 fi @@ -160,7 +160,7 @@ package::python_import() { PYTHON_DUMP_FILE_PATH="${1:-$PYTHON_DUMP_FILE_PATH}" if package::common_import_check pip3 "$PYTHON_DUMP_FILE_PATH"; then - output::write "🚀 Importing Python packages from '$PYTHON_DUMP_FILE_PATH'" | log::file "Importing $pip_title packages list" + output::write "🚀 Importing Python packages from '$PYTHON_DUMP_FILE_PATH'" | log::file "Importing $pip_title packages" pip3 install -r "$PYTHON_DUMP_FILE_PATH" return 0 @@ -174,7 +174,7 @@ package::npm_dump() { if package::common_dump_check npm "$NPM_DUMP_FILE_PATH"; then output::write "🚀 Starting NPM dump to '$NPM_DUMP_FILE_PATH'" - ls -1 /usr/local/lib/node_modules | grep -v npm >|"$NPM_DUMP_FILE_PATH" | log::file "Exporting $npm_title packages list" + ls -1 /usr/local/lib/node_modules | grep -v npm >|"$NPM_DUMP_FILE_PATH" | log::file "Exporting $npm_title packages" return 0 fi @@ -187,7 +187,7 @@ package::npm_import() { if package::common_import_check npm "$NPM_DUMP_FILE_PATH"; then output::write "🚀 Importing NPM packages from '$NPM_DUMP_FILE_PATH'" - xargs -I_ npm install -g "_" < "$NPM_DUMP_FILE_PATH" | log::file "Importing $npm_title packages list" + xargs -I_ npm install -g "_" < "$NPM_DUMP_FILE_PATH" | log::file "Importing $npm_title packages" fi return 1 @@ -198,7 +198,7 @@ package::volta_dump() { if package::common_dump_check volta "$VOLTA_DUMP_FILE_PATH"; then output::write "🚀 Starting VOLTA packages from '$VOLTA_DUMP_FILE_PATH'" - volta list all --format plain | awk '{print $2}' >|"$VOLTA_DUMP_FILE_PATH" | log::file "Exporting $volta_title packages list" + volta list all --format plain | awk '{print $2}' >|"$VOLTA_DUMP_FILE_PATH" | log::file "Exporting $volta_title packages" return 0 fi @@ -211,7 +211,7 @@ package::volta_import() { if package::common_import_check volta "$VOLTA_DUMP_FILE_PATH"; then output::write "🚀 Importing VOLTA packages from '$VOLTA_DUMP_FILE_PATH'" - xargs -I_ volta install "_" <"$VOLTA_DUMP_FILE_PATH" | log::file "Importing ⚡︎⚔️ volta packages list" + xargs -I_ volta install "_" <"$VOLTA_DUMP_FILE_PATH" | log::file "Importing $volta_title packages" return 0 fi @@ -223,7 +223,7 @@ package::cargo_dump() { CARGO_DUMP_FILE_PATH="${1:-$CARGO_DUMP_FILE_PATH}" if package::common_dump_check cargo "$CARGO_DUMP_FILE_PATH"; then - cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' >|"$CARGO_DUMP_FILE_PATH" + cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' >|"$CARGO_DUMP_FILE_PATH" | log::file "Exporting $cargo_title packages" return 0 fi @@ -235,7 +235,7 @@ package::cargo_import() { CARGO_DUMP_FILE_PATH="${1:-$VOLTA_DUMP_FILE_PATH}" if package::common_import_check cargo "$CARGO_DUMP_FILE_PATH"; then - xargs -I_ cargo install < "$CARGO_DUMP_FILE_PATH" + xargs -I_ cargo install < "$CARGO_DUMP_FILE_PATH" | log::file "Importing $cargo_title packages" return 0 fi From 7b84efaa3efbb1fac63f1ed780cda4457e92b478 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Thu, 27 May 2021 23:02:28 +0200 Subject: [PATCH 03/15] Restored dot and output from master to avoid merging problems --- scripts/core/dot.sh | 40 ---------------------------------------- scripts/core/output.sh | 30 +----------------------------- 2 files changed, 1 insertion(+), 69 deletions(-) diff --git a/scripts/core/dot.sh b/scripts/core/dot.sh index 259569956..ddc75cffc 100644 --- a/scripts/core/dot.sh +++ b/scripts/core/dot.sh @@ -32,43 +32,3 @@ dot::list_scripts_path() { printf "%s\n%s" "$dotly_contexts" "$dotfiles_contexts" | sort -u } - -dot::get_script_path() { - echo "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" -} - -dot::get_full_script_path() { - echo "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/$(basename "$0")" -} - -dot::get_script_src_path() { - local lib lib_path lib_paths lib_full_path - lib="${1:-}" - - if [[ -n "${lib:-}" ]]; then - lib_paths=( - "$DOTLY_PATH/scripts/core" - "$(dot::get_script_path)/src" - ) - - [[ -n "${2:-}" ]] && lib_paths+=("$DOTLY_PATH/scripts/$2/src" "$2") - - for lib_path in "${lib_paths[@]}"; do - [[ -f "$lib_path/$lib" ]] &&\ - lib_full_path="$lib_path/$lib" &&\ - break - - [[ -f "$lib_path/$lib.sh" ]] &&\ - lib_full_path="$lib_path/$lib" &&\ - break - done - fi - - # Library loading - if [[ -n "$lib" ]] && [[ -f "$lib_full_path" ]]; then - . "$lib_full_path" - else - output::error "🚨 Library loading error with: \"${lib:-No library provided}\"" - exit 1 - fi -} diff --git a/scripts/core/output.sh b/scripts/core/output.sh index b86d2181b..82eabf7d0 100644 --- a/scripts/core/output.sh +++ b/scripts/core/output.sh @@ -19,41 +19,13 @@ output::error() { output::answer "${red}$1${normal}"; } output::solution() { output::answer "${green}$1${normal}"; } output::question() { if [ platform::is_macos ]; then - echo -n " > 🤔 $1: "; + output::answer "🤔 $1: "; read -r "$2"; else read -rp "🤔 $1: " "$2" fi } -output::question_default() { - local question default_value var_name - [[ $# -ne 3 ]] && return 1 - - question="${1:-}" - default_value="${2:-}" - var_name="${3:-}" - - output::question "$question? [$default_value]" "$var_name" - eval "$var_name=\"\${$var_name:-$default_value}\"" -} -output::yesno() { - local question default PROMPT_REPLY values - - [[ $# -eq 0 ]] && return 1 - - question="$1" - default="${2:-Y}" - - if [[ "$default" =~ ^[Yy] ]]; then - values="Y/n" - else - values="y/N" - fi - - output::question "$question? [$values]" "PROMPT_REPLY" - [[ "${PROMPT_REPLY:-$default}" =~ ^[Yy] ]] -} output::empty_line() { echo ''; } output::header() { output::empty_line; output::write "${bold_blue}---- $1 ----${normal}"; } From 5d991c2a2385b9c098a7403537ea750b297c0d1c Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Sat, 29 May 2021 01:06:40 +0200 Subject: [PATCH 04/15] Added double quotes in _main for DOTLY_PATH because it can contain non alphabetical chars --- scripts/core/_main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/core/_main.sh b/scripts/core/_main.sh index 51d4bc03d..6424eb357 100755 --- a/scripts/core/_main.sh +++ b/scripts/core/_main.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash if ! ${DOT_MAIN_SOURCED:-false}; then - for file in $DOTLY_PATH/scripts/core/{args,array,async,collections,documentation,dot,files,git,log,platform,output,str}.sh; do + for file in "$DOTLY_PATH"/scripts/core/{args,array,async,collections,documentation,dot,files,git,log,platform,output,str}.sh; do #shellcheck source=/dev/null . "$file" || exit 5 done From 4089eae870e3daa29ef2535eab95015256fad1c4 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Sun, 28 Mar 2021 13:37:14 +0200 Subject: [PATCH 05/15] Improved output::join with a stackoverflow function in: https://stackoverflow.com/a/17841619 Removed duplicate functions --- scripts/core/str.sh | 2 +- scripts/self/init | 2 +- scripts/self/utils/init.sh | 82 ++++++++++++++++++++++++++++ shell/init-scripts/dotly_autoupdater | 4 ++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 scripts/self/utils/init.sh create mode 100755 shell/init-scripts/dotly_autoupdater diff --git a/scripts/core/str.sh b/scripts/core/str.sh index 7eb454e61..5601edc7d 100755 --- a/scripts/core/str.sh +++ b/scripts/core/str.sh @@ -15,4 +15,4 @@ str::to_upper() { echo "${@:-$( Date: Sun, 28 Mar 2021 16:13:44 +0200 Subject: [PATCH 06/15] Added closed and unapproved PR #61 because it is needed when I use beta branch for testing and developing. --- bin/dotly | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/dotly b/bin/dotly index 76175d76a..e62d76c53 100755 --- a/bin/dotly +++ b/bin/dotly @@ -6,6 +6,7 @@ source "$DOTLY_PATH/scripts/core/_main.sh" ##? Usage: ##? dotly self-update +##? dotly autoupdate docs::parse "$@" case $1 in From 5ef26e04e8786dacfd3ebf8e710530187a34f38f Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Mon, 29 Mar 2021 02:44:23 +0200 Subject: [PATCH 07/15] Added a way to modify DOTFILES_PATH structure when add a feature to dotly, fixed all the way init-scripts were loaded because they fail. Fixed some issues. --- dotfiles_template/symlinks/conf.yaml | 3 ++ scripts/self/init | 2 +- scripts/symlinks/apply | 65 ++++++++++++++++++++++++---- symlinks/core-feature.yaml | 10 +++++ 4 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 symlinks/core-feature.yaml diff --git a/dotfiles_template/symlinks/conf.yaml b/dotfiles_template/symlinks/conf.yaml index 3fa33d884..159364545 100644 --- a/dotfiles_template/symlinks/conf.yaml +++ b/dotfiles_template/symlinks/conf.yaml @@ -8,6 +8,9 @@ - create: - $DOTFILES_PATH/shell/bash/completions - $DOTFILES_PATH/shell/bash/themes + - $DOTLY_PATH/shell/init-scripts + - $DOTFILES_PATH/shell/init-scripts + - $DOTFILES_PATH/shell/init-scripts.enabled - link: ~/.bash_profile: shell/bash/.bash_profile diff --git a/scripts/self/init b/scripts/self/init index 5f76a1ec2..ca0d81b2c 100755 --- a/scripts/self/init +++ b/scripts/self/init @@ -78,7 +78,7 @@ case "${1:-}" in fi [[ -z "$to_enable" ]] && exit 0 - for item in ${to_enable[@]}; do + for item in "${to_enable[@]}"; do init::enable "$item" if init::status "$item"; then diff --git a/scripts/symlinks/apply b/scripts/symlinks/apply index d20d58c0e..f8b5f72b1 100755 --- a/scripts/symlinks/apply +++ b/scripts/symlinks/apply @@ -13,10 +13,29 @@ symlinks::apply() { echo } +symlinks::get_files() { + [[ -d "$DOTLY_PATH/symlinks" ]] &&\ + find "$DOTLY_PATH/symlinks" -name "*" -type f -print0 |\ + xargs -I _ basename _ | sort +} + +symlinks::fzf() { + local piped_values="$(] +##? +##? Options: +##? -h --help Show this help +##? -v --version Show the program version ##? ##? Options: ##? -h --help Show this help @@ -35,14 +54,44 @@ fi symlinks::apply "conf.yaml" -if platform::is_macos; then - if platform::is_macos_arm; then - symlinks::apply "conf.macos.yaml" +case "${1:-}" in +"update") + if [[ -z "$symlinks_file" ]]; then + symlinks_file="$DOTLY_PATH/symlinks/$(symlinks::get_files | symlinks::fzf)" + [[ -z "$symlinks_file" ]] && exit 0 else - symlinks::apply "conf.macos-intel.yaml" + if [[ -f "$DOTLY_PATH/symlinks/$symlinks_file.yaml" ]]; then + symlinks_file="$DOTLY_PATH/symlinks/$symlinks_file.yaml" + elif [[ -f "$DOTLY_PATH/symlinks/$symlinks_file" ]]; then + symlinks_file="$DOTLY_PATH/symlinks/$symlinks_file" + else + output::error "The file does not exists" + exit 1 + fi + fi + + + output::header "Apply dotbot update to your dotfiles" + output::write "This will apply a selected symlinks to apply any dotly update" + + output::empty_line + "$DOTLY_PATH/modules/dotbot/bin/dotbot" -d "$DOTFILES_PATH" -c "$symlinks_file" + output::empty_line + + output::write "Remember to merge this symlinks file to yours in:" + output::answer "$DOTFILES_PATH/symlinks/conf.yaml" + ;; +*) + symlinks::apply "conf.yaml" + + if platform::is_macos; then + if platform::is_macos_arm; then + symlinks::apply "conf.macos.yaml" + else + symlinks::apply "conf.macos-intel.yaml" + fi + else + symlinks::apply "conf.linux.yaml" fi -else - symlinks::apply "conf.linux.yaml" -fi -log::success "Done!" \ No newline at end of file +log::success "Done!" diff --git a/symlinks/core-feature.yaml b/symlinks/core-feature.yaml new file mode 100644 index 000000000..7d66113e8 --- /dev/null +++ b/symlinks/core-feature.yaml @@ -0,0 +1,10 @@ +- defaults: + link: + create: true + force: true + +- create: + - $DOTLY_PATH/shell/init-scripts + - $DOTFILES_PATH/shell/init-scripts + - $DOTFILES_PATH/shell/init-scripts.enabled + From 17e1a79e46eff0666b4fbff11c6ea33126dbb507 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Thu, 1 Apr 2021 00:00:40 +0200 Subject: [PATCH 08/15] Added some core functions: * Added new functions to get the current script_name or script_path where the functions were run * Added function to conver mayus to lower --- scripts/dotfiles/create | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/dotfiles/create b/scripts/dotfiles/create index 6ffcb3332..9b0f3f777 100755 --- a/scripts/dotfiles/create +++ b/scripts/dotfiles/create @@ -20,7 +20,11 @@ dotfiles::apply_templating() { ) for file in "${tpl_files[@]}"; do +<<<<<<< HEAD templating::replace "$file" --dotfiles-path="${DOTFILES_PATH//$HOME/\$HOME}" +======= + templating::replace "$file" --dotfiles-path="$DOTFILES_PATH" +>>>>>>> eaabc09 (Added some core functions:) done } From c63122bd5f8c890dd43c545bf7bb395b3b51a68c Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Thu, 1 Apr 2021 17:31:21 +0200 Subject: [PATCH 09/15] Added async library Added script 'dot symlinks update' --- scripts/symlinks/apply | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/scripts/symlinks/apply b/scripts/symlinks/apply index f8b5f72b1..a953751c4 100755 --- a/scripts/symlinks/apply +++ b/scripts/symlinks/apply @@ -13,25 +13,10 @@ symlinks::apply() { echo } -symlinks::get_files() { - [[ -d "$DOTLY_PATH/symlinks" ]] &&\ - find "$DOTLY_PATH/symlinks" -name "*" -type f -print0 |\ - xargs -I _ basename _ | sort -} - -symlinks::fzf() { - local piped_values="$(] ##? ##? Options: ##? -h --help Show this help @@ -78,20 +63,14 @@ case "${1:-}" in "$DOTLY_PATH/modules/dotbot/bin/dotbot" -d "$DOTFILES_PATH" -c "$symlinks_file" output::empty_line - output::write "Remember to merge this symlinks file to yours in:" - output::answer "$DOTFILES_PATH/symlinks/conf.yaml" - ;; -*) - symlinks::apply "conf.yaml" - - if platform::is_macos; then - if platform::is_macos_arm; then - symlinks::apply "conf.macos.yaml" - else - symlinks::apply "conf.macos-intel.yaml" - fi +if platform::is_macos; then + if platform::is_macos_arm; then + symlinks::apply "conf.macos.yaml" else - symlinks::apply "conf.linux.yaml" + symlinks::apply "conf.macos-intel.yaml" fi +else + symlinks::apply "conf.linux.yaml" +fi log::success "Done!" From 43d41423e526bf138a6a1c1d01c68a08b6c3dc37 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Mon, 31 May 2021 17:45:09 +0200 Subject: [PATCH 10/15] Added couple of kill to view the effecto of importing defaults --- scripts/mac/defaults | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/mac/defaults b/scripts/mac/defaults index 2e8e015c7..b6fb73fb4 100755 --- a/scripts/mac/defaults +++ b/scripts/mac/defaults @@ -67,6 +67,11 @@ case $1 in done output::solution "Defaults '$import_name' imported." fi + + killall Dock + killall Finder + output::answer "A Reboot is suggested" + output::yesno "Do you want to reboot now" && sudo reboot ;; *) exit 1 From 6afe2e1d5d2d463050d5316a7e3ae69643e5188d Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Mon, 31 May 2021 17:55:14 +0200 Subject: [PATCH 11/15] Fixed not well included dump.sh library --- scripts/mac/brew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mac/brew b/scripts/mac/brew index 97b6162e6..178e745ff 100755 --- a/scripts/mac/brew +++ b/scripts/mac/brew @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$DOTLY_PATH/scripts/core/_main.sh" -source "$DOTLY_PATH/scripts/package/utils/dump.sh" +dot::get_script_src_path "dump.sh" "package" ##? Some brew utils. ##? - If cleanup does not receive any param will take your From 8317fa2e4658b3f4657352265f60e8afe4185617 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Mon, 31 May 2021 17:45:09 +0200 Subject: [PATCH 12/15] Added couple of kill to view the effect of importing defaults --- scripts/mac/defaults | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/mac/defaults b/scripts/mac/defaults index 2e8e015c7..b6fb73fb4 100755 --- a/scripts/mac/defaults +++ b/scripts/mac/defaults @@ -67,6 +67,11 @@ case $1 in done output::solution "Defaults '$import_name' imported." fi + + killall Dock + killall Finder + output::answer "A Reboot is suggested" + output::yesno "Do you want to reboot now" && sudo reboot ;; *) exit 1 From 6dd661c9b092ba5e5e44e48cbdc7c26f2c25cbf0 Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Mon, 31 May 2021 17:55:14 +0200 Subject: [PATCH 13/15] Fixed not well included dump.sh library --- scripts/mac/brew | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mac/brew b/scripts/mac/brew index 97b6162e6..178e745ff 100755 --- a/scripts/mac/brew +++ b/scripts/mac/brew @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$DOTLY_PATH/scripts/core/_main.sh" -source "$DOTLY_PATH/scripts/package/utils/dump.sh" +dot::get_script_src_path "dump.sh" "package" ##? Some brew utils. ##? - If cleanup does not receive any param will take your From 0c516e83bc4b8bf7e550308562f6f8d0746d040e Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Wed, 2 Jun 2021 12:59:22 +0200 Subject: [PATCH 14/15] Fix update when no update yaml file is given and no choose in fzf selection --- scripts/symlinks/update | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/symlinks/update b/scripts/symlinks/update index fd5191ce0..7612b19ea 100755 --- a/scripts/symlinks/update +++ b/scripts/symlinks/update @@ -43,8 +43,9 @@ fi if [[ -z "$symlinks_file" ]]; then - symlinks_file="$DOTLY_PATH/symlinks/$(symlinks::get_files | symlinks::fzf)" + symlinks_file="$(symlinks::get_files | symlinks::fzf)" [[ -z "$symlinks_file" ]] && exit 0 + symlinks_file="$DOTLY_PATH/symlinks/$symlinks_file" else for f in "$symlinks_file" "$symlinks_file.yaml" "$symlinks_file.yml"; do [[ -e "$f" ]] && symlinks_file="$f" && break From 9e8e7ae15e15cc68f727ceac0d904d7341a424de Mon Sep 17 00:00:00 2001 From: Gabriel Trabanco Llano Date: Thu, 3 Jun 2021 16:56:07 +0200 Subject: [PATCH 15/15] Changed the name of dot::get_script_src_path to dot::load_library. --- scripts/mac/brew | 2 +- scripts/package/dump | 2 +- scripts/package/import | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mac/brew b/scripts/mac/brew index 178e745ff..f802f9941 100755 --- a/scripts/mac/brew +++ b/scripts/mac/brew @@ -1,7 +1,7 @@ #!/usr/bin/env bash source "$DOTLY_PATH/scripts/core/_main.sh" -dot::get_script_src_path "dump.sh" "package" +dot::load_library "dump.sh" "package" ##? Some brew utils. ##? - If cleanup does not receive any param will take your diff --git a/scripts/package/dump b/scripts/package/dump index db4aea931..910a1eeab 100755 --- a/scripts/package/dump +++ b/scripts/package/dump @@ -1,7 +1,7 @@ #!/usr/bin/env bash . "$DOTLY_PATH/scripts/core/_main.sh" -dot::get_script_src_path "dump.sh" +dot::load_library "dump.sh" ##? Dump all installed packages from: ##? * Brew diff --git a/scripts/package/import b/scripts/package/import index ad45ed1ef..59ff7dc35 100755 --- a/scripts/package/import +++ b/scripts/package/import @@ -1,7 +1,7 @@ #!/usr/bin/env bash . "$DOTLY_PATH/scripts/core/_main.sh" -dot::get_script_src_path "dump.sh" +dot::load_library "dump.sh" ##? Import previously dumped packages from: ##? * Brew