fix: import envs in ghostty
This commit is contained in:
1
config/shell/.config/fish/prev.d/.gitignore
vendored
1
config/shell/.config/fish/prev.d/.gitignore
vendored
@@ -3,3 +3,4 @@
|
||||
!prompt.fish
|
||||
!theme.fish
|
||||
!env.fish
|
||||
!niri-env.fish
|
||||
22
config/shell/.config/fish/prev.d/niri-env.fish
Normal file
22
config/shell/.config/fish/prev.d/niri-env.fish
Normal 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
|
||||
Reference in New Issue
Block a user