From a44f38820ec943643d0292ece6ff48958369e856 Mon Sep 17 00:00:00 2001 From: thek4n Date: Tue, 23 Jul 2024 00:17:41 +0300 Subject: [PATCH] fix termux --- install | 22 ++++++++++++++-------- install-hooks/termux/post-install | 7 ++++++- 2 files changed, 20 insertions(+), 9 deletions(-) mode change 100644 => 100755 install-hooks/termux/post-install diff --git a/install b/install index 879dcbe..4e34221 100755 --- a/install +++ b/install @@ -1,24 +1,29 @@ -#!/bin/bash +#!/usr/bin/env bash set -ueo pipefail shopt -s nullglob declare -r TARGET_PATH="$HOME" -declare -r DOTFILES_ROOT="$PWD" + + +_detect_current_script_real_directory() { + realpath -e -- "$(dirname -- "$(readlink -e -- "${BASH_SOURCE[0]:-$0}")")" +} + +declare DOTFILES_ROOT +DOTFILES_ROOT="$(_detect_current_script_real_directory)" +readonly DOTFILES_ROOT + declare -xr SUB="$DOTFILES_ROOT/home/user" +source "$DOTFILES_ROOT/TARGETS.sh" + _die() { echo "$0: $1" >&2 exit $2 } -test "$0" = "./install" || _die "Error: Please, run this file from root of dotfiles, like this './install.sh TARGET" 1 - - -source "$DOTFILES_ROOT/TARGETS.sh" - - _link_files_in_sandbox() { local targetfile for targetfile in "$@" @@ -60,6 +65,7 @@ __install_from_sandbox() { } _execute_hook_if_executable() { + # all hooks gets SUB and SANDBOX_PATH env variables local hook_path="$DOTFILES_ROOT/install-hooks/$1/$2" if [ -x "$hook_path" ]; then echo "Executing $2 for target '$1'" diff --git a/install-hooks/termux/post-install b/install-hooks/termux/post-install old mode 100644 new mode 100755 index 15414a9..fcd395d --- a/install-hooks/termux/post-install +++ b/install-hooks/termux/post-install @@ -1,3 +1,8 @@ #!/usr/bin/env bash -cp -r home/user/.shortcuts "$HOME" \ No newline at end of file + +if [[ -d "$HOME/.shortcuts" ]]; then + cp "$SUB/.shortcuts/*" "$HOME/.shortcuts" +else + cp -r "$SUB/.shortcuts" "$HOME" +fi \ No newline at end of file