Entry tags:
Линуксисту на заметку
Полезные примитивы управления путём 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
no subject
no subject