From c333bbf93c7d9b78bc05a34a6c0885100ab21b93 Mon Sep 17 00:00:00 2001 From: adikpb <67222969+adikpb@users.noreply.github.com> Date: Mon, 10 Jun 2024 23:39:37 +0400 Subject: [PATCH] fix: fish PATH append/prepend gets duplicated ofek/userpath#57 --- userpath/shells.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/userpath/shells.py b/userpath/shells.py index 66114d4..6aaca09 100644 --- a/userpath/shells.py +++ b/userpath/shells.py @@ -56,12 +56,11 @@ def show_path_commands(cls): class Fish(Shell): def config(self, location, front=True): location = ' '.join(location.split(pathsep)) - head, tail = (location, '$PATH') if front else ('$PATH', location) + arg = "-" + ("p" if front else "a") - # https://github.com/fish-shell/fish-shell/issues/527#issuecomment-12436286 - contents = 'set PATH {} {}'.format(head, tail) + contents = f"contains {location} $PATH; or set -gx {arg} PATH {location}" - return {path.join(self.home, '.config', 'fish', 'config.fish'): contents} + return {path.join(self.home, ".config", "fish", "config.fish"): contents} @classmethod def show_path_commands(cls):