vak: (Знайка)
[personal profile] vak
Полезные примитивы управления путём PATH. Вставляются в ~/.bashrc. Правятся по вкусу.
append_path() {
    local dir="$1"
    if [[ -d "$dir" ]]; then
        if [[ -d "$dir" && ":$PATH:" != *":$dir:"* ]]; then
            export PATH="$PATH:$dir"
        fi
    fi
}
prepend_path() {
    local dir="$1"
    if [[ -d "$dir" ]]; then
        if [[ -d "$dir" && ":$PATH:" != *":$dir:"* ]]; then
            export PATH="$dir:$PATH"
        fi
    fi
}
remove_path() {
    local dir="$1"
    if [[ ":$PATH:" == *":$dir:"* ]]; then
        local new_path=":$PATH:"
        new_path="${new_path//:$dir:/:}"
        new_path="${new_path#:}"
        export PATH="${new_path%:}"
    fi
}
remove_path /usr/games
remove_path /usr/local/games
remove_path .
append_path /usr/sbin
append_path /usr/bin
append_path /snap/bin
prepend_path /usr/local/bin
prepend_path /usr/local/sbin
prepend_path $HOME/.local/bin
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org