rename env var

This commit is contained in:
Mitchell Hashimoto
2024-05-27 16:18:51 -07:00
parent 982e4c9570
commit 66a9b1b99f
3 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ {
fn restore-xdg-dirs { fn restore-xdg-dirs {
var integration-dir = $E:GHOSTTY_INTEGRATION_DIR var integration-dir = $E:GHOSTTY_SHELL_INTEGRATION_XDG_DIR
var xdg-dirs = [(str:split ':' $E:XDG_DATA_DIRS)] var xdg-dirs = [(str:split ':' $E:XDG_DATA_DIRS)]
var len = (count $xdg-dirs) var len = (count $xdg-dirs)
@ -27,9 +27,9 @@
} else { } else {
set-env XDG_DATA_DIRS (str:join ':' $xdg-dirs) set-env XDG_DATA_DIRS (str:join ':' $xdg-dirs)
} }
unset-env GHOSTTY_INTEGRATION_DIR unset-env GHOSTTY_SHELL_INTEGRATION_XDG_DIR
} }
if (and (has-env GHOSTTY_INTEGRATION_DIR) (has-env XDG_DATA_DIRS)) { if (and (has-env GHOSTTY_SHELL_INTEGRATION_XDG_DIR) (has-env XDG_DATA_DIRS)) {
restore-xdg-dirs restore-xdg-dirs
} }
} }

View File

@ -6,7 +6,7 @@
function ghostty_restore_xdg_data_dir -d "restore the original XDG_DATA_DIR value" function ghostty_restore_xdg_data_dir -d "restore the original XDG_DATA_DIR value"
# If we don't have our own data dir then we don't need to do anything. # If we don't have our own data dir then we don't need to do anything.
if not set -q GHOSTTY_INTEGRATION_DIR if not set -q GHOSTTY_SHELL_INTEGRATION_XDG_DIR
return return
end end
@ -19,7 +19,7 @@ function ghostty_restore_xdg_data_dir -d "restore the original XDG_DATA_DIR valu
set --function --path xdg_data_dirs "$XDG_DATA_DIRS" set --function --path xdg_data_dirs "$XDG_DATA_DIRS"
# If our data dir is in the list then remove it. # If our data dir is in the list then remove it.
if set --function index (contains --index "$GHOSTTY_INTEGRATION_DIR" $xdg_data_dirs) if set --function index (contains --index "$GHOSTTY_SHELL_INTEGRATION_XDG_DIR" $xdg_data_dirs)
set --erase --function xdg_data_dirs[$index] set --erase --function xdg_data_dirs[$index]
end end
@ -30,7 +30,7 @@ function ghostty_restore_xdg_data_dir -d "restore the original XDG_DATA_DIR valu
set --erase --global XDG_DATA_DIRS set --erase --global XDG_DATA_DIRS
end end
set --erase GHOSTTY_INTEGRATION_DIR set --erase GHOSTTY_SHELL_INTEGRATION_XDG_DIR
end end
function ghostty_exit -d "exit the shell integration setup" function ghostty_exit -d "exit the shell integration setup"

View File

@ -419,8 +419,8 @@ test "bash: preserve ENV" {
/// their modules from paths in `XDG_DATA_DIRS` env variable. /// their modules from paths in `XDG_DATA_DIRS` env variable.
/// ///
/// Path of shell-integration dir is prepended to `XDG_DATA_DIRS`. /// Path of shell-integration dir is prepended to `XDG_DATA_DIRS`.
/// It is also saved in `GHOSTTY_INTEGRATION_DIR` variable so that /// It is also saved in `GHOSTTY_SHELL_INTEGRATION_XDG_DIR` variable
/// the shell can refer to it and safely remove this directory /// so that the shell can refer to it and safely remove this directory
/// from `XDG_DATA_DIRS` when integration is complete. /// from `XDG_DATA_DIRS` when integration is complete.
fn setupXdgDataDirs( fn setupXdgDataDirs(
alloc_arena: Allocator, alloc_arena: Allocator,
@ -439,7 +439,7 @@ fn setupXdgDataDirs(
// Set an env var so we can remove this from XDG_DATA_DIRS later. // Set an env var so we can remove this from XDG_DATA_DIRS later.
// This happens in the shell integration config itself. We do this // This happens in the shell integration config itself. We do this
// so that our modifications don't interfere with other commands. // so that our modifications don't interfere with other commands.
try env.put("GHOSTTY_INTEGRATION_DIR", integ_dir); try env.put("GHOSTTY_SHELL_INTEGRATION_XDG_DIR", integ_dir);
if (env.get("XDG_DATA_DIRS")) |old| { if (env.get("XDG_DATA_DIRS")) |old| {
// We have an old value, We need to prepend our value to it. // We have an old value, We need to prepend our value to it.