From d42d8fa55307820afbe0eab7cc92bd63c6325169 Mon Sep 17 00:00:00 2001 From: Daniel Mladek <5643604+delphym@users.noreply.github.com> Date: Wed, 3 Apr 2019 14:33:58 +1300 Subject: [PATCH 1/2] Corrected what is the expected value of the $CURRENT_DIR It is neccessary for the cases when runnign the scripts without a possibility of using key bindings as adviced in issue #179 https://github.com/tmux-plugins/tmux-resurrect/issues/179 The case is e.g. saving the sessions for byobu and having the symlinks created at $HOME/bin/ as: byobu-session-restore -> /home/delphym/.tmux/plugins/tmux-resurrect/scripts/restore.sh byobu-session-save -> /home/delphym/.tmux/plugins/tmux-resurrect/scripts/save.sh --- scripts/restore.sh | 11 ++++++++++- scripts/save.sh | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index 4104af3..bafdece 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -1,7 +1,16 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Absolute path to this script, e.g. /home/user/.tmux/plugins/tmux-resurrect/scripts/save.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/.tmux/plugins/tmux-resurrect/scripts +SCRIPT_PATH=$(dirname "$SCRIPT") +echo "SCRIPT_PATH -> $SCRIPT_PATH" +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo "CURRENT_DIR -> $CURRENT_DIR" + +# $CURRENT_DIR seems is expected to be an absolut path this script is located in +CURRENT_DIR="$SCRIPT_PATH" source "$CURRENT_DIR/variables.sh" source "$CURRENT_DIR/helpers.sh" source "$CURRENT_DIR/process_restore_helpers.sh" diff --git a/scripts/save.sh b/scripts/save.sh index 9d80af7..cc398ba 100755 --- a/scripts/save.sh +++ b/scripts/save.sh @@ -1,6 +1,16 @@ #!/usr/bin/env bash +# Absolute path to this script, e.g. /home/user/.tmux/plugins/tmux-resurrect/scripts/save.sh +SCRIPT=$(readlink -f "$0") +# Absolute path this script is in, thus /home/user/.tmux/plugins/tmux-resurrect/scripts +SCRIPT_PATH=$(dirname "$SCRIPT") +echo "SCRIPT_PATH -> $SCRIPT_PATH" + CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +echo "CURRENT_DIR -> $CURRENT_DIR" + +# $CURRENT_DIR seems is expected to be an absolut path this script is located in +CURRENT_DIR="$SCRIPT_PATH" source "$CURRENT_DIR/variables.sh" source "$CURRENT_DIR/helpers.sh" From 7e0e42a52afd2fbea0ebe26ce25aa8e2d3669a87 Mon Sep 17 00:00:00 2001 From: Daniel Mladek <5643604+delphym@users.noreply.github.com> Date: Wed, 3 Apr 2019 14:42:50 +1300 Subject: [PATCH 2/2] Just formatting. --- scripts/restore.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore.sh b/scripts/restore.sh index bafdece..3114e43 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -11,6 +11,7 @@ echo "CURRENT_DIR -> $CURRENT_DIR" # $CURRENT_DIR seems is expected to be an absolut path this script is located in CURRENT_DIR="$SCRIPT_PATH" + source "$CURRENT_DIR/variables.sh" source "$CURRENT_DIR/helpers.sh" source "$CURRENT_DIR/process_restore_helpers.sh"