fix: import envs in ghostty

This commit is contained in:
2025-12-01 01:14:16 +01:00
parent 34a2f71c6d
commit 8f9df4c730
7 changed files with 34 additions and 10 deletions

View File

@@ -3,3 +3,4 @@
!prompt.fish
!theme.fish
!env.fish
!niri-env.fish

View File

@@ -0,0 +1,22 @@
if test $XDG_CURRENT_DESKTOP = "niri"
set -l env_config "$HOME/.config/niri/config/envs.kdl"
if test -f "$env_config"
while read -la line
# Remove comments
set line (string replace -r '//.*' '' -- "$line")
# Trim whitespace
set line (string trim -- "$line")
# Skip "environment" block lines
if test -z "$line"; or string match -q "environment*" -- "$line"; or test "$line" = "}"
continue
end
# Match lines like: VARIABLE "value" where VARIABLE is alphanumeric/underscore
set -l matches (string match -r '^([0-9A-Za-z_]+)\s+"(.*)"$' -- "$line")
# If have a matches, set the environment variable
if test (count $matches) -eq 3
set -xg $matches[2] $matches[3]
end
end < "$env_config"
end
end