i've been configuring my system and when i checked my PATH there were duplicates. so i started trying to deduplicate it for tidiness, so far i've been messing around with 90-user.conf and .profile files. i also did some other stuff in my nushell configs but that's because of how nushell works, so i don't have much doubts about that.

i'll try to be as clear, concise as possible, but since i've started doing this stuff very recently i might not exactly know where to aim my question. so i guess i have doubts regarding if this is a correct way to handle PATH declaration and deduplication. from what i understand, i need to define it in various places because having a correct path depends largely on where you're inheriting it. so maybe your GUI session has a proper PATH, but if you log in through a TTY or similar you might have a different one. also different files also add their own stuff. so should i only care about these 2 files to have a proper file or is there something else i should keep in mind? is the reasoning correct?

if you need some other file just let me know and i'll share it if it's useful. below is system information in case it's relevant.

❯ fastfetch

╭─ システム                    [ghost-user]
│
│ os Fedora Linux 43
│ kernel 7.2.13-100.fc43.x86_64
│ age 345 days
│ uptime 8 hours, 10 mins
│ shell nushell 0.99.1
│ de GNOME 49.10
│ wm Mutter (Wayland)
│ cpu AMD Ryzen 5 5600G 4.46 GHz
│ memory 5.23 GiB / 7.05 GiB (74%)
│
│                                過去を殺せ
╰──────────────────────────────────────────

#90-user.conf

EDITOR=hx
BROWSER=firefox
XDG_DATA_HOME=$HOME/.local/share
XDG_CONFIG_HOME=$HOME/.config
XDG_CACHE_HOME=$HOME/.cache

PATH=$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.opencode/bin:/usr/local/go/bin${PATH:+:$PATH}
PKG_CONFIG_PATH=/usr/lib64/pkgconfig
#.profile

export _DOTFILES_PROFILE_SOURCED=1

case ":$PATH:" in *":$HOME/.opencode/bin:"*) ;; *) PATH="$HOME/.opencode/bin:$PATH" ;; esac

[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"

case ":$PATH:" in *":/usr/local/go/bin:"*) ;; *) PATH="$PATH:/usr/local/go/bin" ;; esac

if [ -n "$PATH" ]; then
    pinned=""
    IFS_OLD=$IFS
    IFS=:
    for _d in $PATH; do
        [ -z "$_d" ] && continue
        case ":$pinned:" in *":$_d:"*) continue ;; esac
        [ "$_d" = "$HOME/.local/bin" ] && continue
        pinned="${pinned}${pinned:+:}${_d}"
    done
    IFS=$IFS_OLD
    unset _d
    export PATH="$HOME/.local/bin:$pinned"
fi

verification:

#bash

❯ echo "$PATH" | tr ':' '\n'
/home/ghost_user/.local/bin
/usr/lib64/ccache
/home/ghost_user/.cargo/bin
/home/ghost_user/.opencode/bin
/usr/local/go/bin
/usr/local/bin
/usr/bin
#nushell

❯ $env.PATH
╭───┬────────────────────────────────╮
│ 0 │ /home/ghost_user/.local/bin    │
│ 1 │ /usr/lib64/ccache              │
│ 2 │ /home/ghost_user/.cargo/bin    │
│ 3 │ /home/ghost_user/.opencode/bin │
│ 4 │ /usr/local/go/bin              │
│ 5 │ /usr/local/bin                 │
│ 6 │ /usr/bin                       │
╰───┴────────────────────────────────╯

no comments (yet)

sorted by: hot top controversial new old
there doesn't seem to be anything here