Skip to content

Commit

Permalink
Fix: Use unique session names for tmp env storage
Browse files Browse the repository at this point in the history
Otherwise running multiple zide sessions at once conflicts with env var
values
  • Loading branch information
josephschmitt committed Feb 7, 2025
1 parent 464db3e commit 35aea93
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bin/zide
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ fi

# Export location of the zide project files for further use
export ZIDE_DIR=$(dirname "$script_dir")
export ZIDE_SESSION_NAME="session_$(date +%Y%m%d_%H%M%S)_$RANDOM"
export ZIDE_FILE_PICKER=${picker:-${ZIDE_FILE_PICKER}}
export ZIDE_CURRENT_LAYOUT="${layout}"
export ZIDE_ORIGINAL_EDITOR="${EDITOR}"
Expand All @@ -123,7 +124,7 @@ export ZIDE_TAB_NAME="${name}"
# Dump env vars to disk so they can be restored across tabs and panes
tmpDir="${ZIDE_DIR}/tmp"
mkdir -p "${tmpDir}"
printenv | grep ZIDE_ | sed 's/^/export /; s/=/="/; s/$/"/' > "${tmpDir}/env"
printenv | grep ZIDE_ | sed 's/^/export /; s/=/="/; s/$/"/' > "${tmpDir}/${ZIDE_SESSION_NAME}_env"

layout_path="$ZIDE_DIR/layouts/$layout"
if [ -n "$ZELLIJ" ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/zide-edit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

source "${ZIDE_DIR}/tmp/env"
source "${ZIDE_DIR}/tmp/${ZIDE_SESSION_NAME}_env"
source "${ZIDE_DIR}/bin/lib/getEditorCommand.sh"

read -r -d '' HELP_TEXT << EOF
Expand Down
2 changes: 1 addition & 1 deletion bin/zide-pick
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

source "${ZIDE_DIR}/tmp/${ZIDE_SESSION_NAME}_env"
source "${ZIDE_DIR}/bin/lib/findLayoutConfig.sh"
source "${ZIDE_DIR}/tmp/env"

read -r -d '' HELP_TEXT << EOF
Usage: $(basename "$0") [OPTIONS] <working_dir>
Expand Down
2 changes: 1 addition & 1 deletion bin/zide-rename
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

source "${ZIDE_DIR}/tmp/env"
source "${ZIDE_DIR}/tmp/${ZIDE_SESSION_NAME}_env"

read -r -d '' HELP_TEXT << EOF
Usage: $(basename "$0") <name>
Expand Down

0 comments on commit 35aea93

Please sign in to comment.