changed PATH sourcing

This commit is contained in:
2026-04-04 13:43:38 +03:00
parent a426a664af
commit d955457f12

View File

@@ -1,3 +1,11 @@
while read -l line
if string match -q "PATH=*" $line
set -l path_value (string replace "PATH=" "" $line)
fish_add_path (eval echo $path_value)
end
end < ~/.env
if status is-interactive if status is-interactive
# Commands to run for interactive sessions go here # Commands to run for interactive sessions go here
source ~/.config/fish/aliases.fish source ~/.config/fish/aliases.fish
@@ -9,40 +17,66 @@ if test -f ~/.config/fish/conf.d/.secrets.fish
end end
# Make tmux run by default on ssh connections # Make tmux run by default on ssh connections
if status is-interactive; and test -n "$SSH_CONNECTION"; and test -z "$TMUX"; and type -q tmux # if status is-interactive; and test -n "$SSH_CONNECTION"; and test -z "$TMUX"; and type -q tmux
tmux attach-session -t default 2>/dev/null; or tmux new-session -s default # tmux attach-session -t default 2>/dev/null; or tmux new-session -s default
end # end
# PATH additions (deduplicated with fish_add_path) # PATH additions (deduplicated with fish_add_path)
# fish_add_path ~/.local/bin ~/.opencode/bin /opt/nvim-linux-x86_64/bin ~/.cargo/bin # fish_add_path ~/.local/bin ~/.opencode/bin /opt/nvim-linux-x86_64/bin ~/.cargo/bin
# Source ~/.env file with PATH deduplication # Source ~/.env file with PATH deduplication Claude
if test -f ~/.env # while read -l line
# Read .env file line by line # if string match -qr '^[A-Z_]+=.*' -- $line
while read -l line # set -xg (string split -m 1 '=' $line)
# Skip empty lines and comments # end
if test -z "$line"; or string match -q "#*" "$line" # end < ~/.env
continue
end
# Check if line sets PATH
if string match -q "PATH=*" "$line" # while read -l line
# Extract PATH value after = # if string match -q "PATH=*" $line
set -l path_value (string replace "PATH=" "" "$line") # set -l path_value (string replace "PATH=" "" $line)
# Split by : and add each path # fish_add_path (eval echo $path_value)
for p in (string split ":" "$path_value") # end
if test -n "$p" # end < ~/.env
fish_add_path "$p"
end
end
else # # Source ~/.env file with PATH deduplication
# Export other variables normally # if test -f ~/.env
set -l var_name (string split "=" "$line")[1] # # Read .env file line by line
set -l var_value (string replace "$var_name=" "" "$line") # echo "DEBUG: About to read .env file" >&2
set -gx "$var_name" "$var_value" # while read -l line
end # # Skip empty lines and comments
end < ~/.env # if test -z "$line"; or string match -q "#*" "$line"
end # continue
# end
# echo "DEBUG: Processing line: '$line'" >&2
# # Check if line sets PATH
# if string match -q "PATH=*" "$line"
# # Extract PATH value after =
# set -l path_value (string replace "PATH=" "" "$line")
#
# # Safely expand known variables in PATH
# set -l expanded_path (string replace '$HOME' $HOME "$path_value")
# set expanded_path (string replace '$USER' $USER "$expanded_path")
# set expanded_path (string replace '$XDG_CONFIG_HOME' $XDG_CONFIG_HOME "$expanded_path")
# set expanded_path (string replace '$XDG_DATA_HOME' $XDG_DATA_HOME "$expanded_path")
# echo "DEBUG: Expanded path: '$expanded_path'" >&2
#
# # Split by : and add each path
# for p in (string split ":" "$expanded_path")
# if test -n "$p"
# fish_add_path "$p"
# end
# end
# else
# # Export other variables normally
# set -l var_name (string split "=" "$line")[1]
# set -l var_value (string replace "$var_name=" "" "$line")
# set -gx "$var_name" "$var_value"
# end
# end < ~/.env
# end
# Netbird completion script # Netbird completion script
# fish completion for netbird -*- shell-script -*- # fish completion for netbird -*- shell-script -*-