Skip to content

Commit

Permalink
Some formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrabanco committed Jun 28, 2024
1 parent 961d348 commit 1e6e52d
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 283 deletions.
102 changes: 51 additions & 51 deletions scripts/core/install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -376,15 +376,15 @@ 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\`'

output::empty_line
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\`"
Expand Down
Loading

0 comments on commit 1e6e52d

Please sign in to comment.