From a9a87992dfd06e5b9fce6c684651a0f9525ad85d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 2 Apr 2016 22:28:36 +0200 Subject: [PATCH] load_session: prefer existing session instead of file in cwd This also adds './' to a file used from the current working dir (in case there is no session with that name), which is required for Bash's `source` to use it (and not look for it in `$PATH`). Fixes https://github.com/jimeh/tmuxifier/issues/69. --- lib/layout-helpers.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/layout-helpers.sh b/lib/layout-helpers.sh index 7ac787e..6f7491c 100644 --- a/lib/layout-helpers.sh +++ b/lib/layout-helpers.sh @@ -189,9 +189,17 @@ load_window() { # - $2: (optional) Override default window name. # load_session() { - local file="$1" - if [ ! -f "$file" ]; then - file="$TMUXIFIER_LAYOUT_PATH/$1.session.sh" + local file + if [ "${1#*/}" = "$1" ]; then + # There's no slash in the path. + if [ -f "$TMUXIFIER_LAYOUT_PATH/$1.session.sh" ] || [ ! -f "$1" ]; then + file="$TMUXIFIER_LAYOUT_PATH/$1.session.sh" + else + # bash's 'source' requires an slash in the filename to not use $PATH. + file="./$1" + fi + else + file="$1" fi if [ -f "$file" ]; then