Skip to content

Commit fe3d2ba

Browse files
bash: prevent duplicate in PATH and warn about fish_user_paths == ''
1 parent af1abce commit fe3d2ba

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

bash/bashrc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ export EDITOR=nvim
22
export VISUAL=nvim
33
export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh
44

5-
# Find the location of my dotfiles.
6-
# Adapted from: https://stackoverflow.com/a/246128
5+
# Find the location of my dotfiles. Adapted from <https://stackoverflow.com/a/246128>.
76
export DOTFILES=$( cd -P "$( dirname $(readlink "${BASH_SOURCE[0]}") )/.." >/dev/null 2>&1 && pwd )
87

9-
export PATH=$PATH:$DOTFILES/bin
8+
# Add directories to `PATH`, but avoid duplicates (see: <https://superuser.com/a/1333564>).
9+
[ "${PATH#*:$DOTFILES/bin}" == "$PATH" ] && export PATH=$PATH:$DOTFILES/bin
10+
# [ "${PATH#*$EXAMPLE/bin:}" == "$PATH" ] && export PATH="$EXAMPLE/bin:$PATH"
11+
12+
# WARN: `fish_user_paths` MUST NOT be an empty string (instead of an empty list). It is prepended to
13+
# `PATH`, where an empty string is interpreted as `.` – the current directory.
1014

1115
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
1216
# Run QT applications on Wayland.

0 commit comments

Comments
 (0)