From fb21c7fceab24c7ecd7a9aaf89e6203cf242a38e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 3 Dec 2023 10:12:46 +0200 Subject: bashrc: de-duplicate $PATH if pathdeup is available Signed-off-by: Lars Wirzenius Sponsored-by: author --- bashrc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'bashrc') diff --git a/bashrc b/bashrc index 9fdaa58..6d32737 100644 --- a/bashrc +++ b/bashrc @@ -147,7 +147,7 @@ prompt_set_window_title() { prompt_command() { tell_about_exit_code "$?" PS1="$(define_ps1)" - prompt_set_window_title + prompt_set_window_title } ############### @@ -155,10 +155,9 @@ prompt_command() { ulimit -c 0 umask 002 - # Get environment variables from systemd, if any are set. -if systemctl --user show-environment > /dev/null 2>&1; then - . <(systemctl --user show-environment | sed 's/^/export /') +if systemctl --user show-environment >/dev/null 2>&1; then + . <(systemctl --user show-environment | sed 's/^/export /') fi if command -v emacs >/dev/null; then @@ -181,7 +180,6 @@ export ANSIBLE_STDOUT_CALLBACK=yaml export PYTHONDONTWRITEBYTECODE=1 export STARSHIP_CONFIG=~/.config/starship/config.toml - if [ -e "$HOME/tmp/cargo" ]; then export CARGO_TARGET_DIR="$HOME/tmp/cargo" elif [ -e "$HOME/cargo" ]; then @@ -189,7 +187,7 @@ elif [ -e "$HOME/cargo" ]; then fi if [ -e "$HOME/tmp" ]; then - export TMPDIR="$HOME/tmp" + export TMPDIR="$HOME/tmp" fi PROMPT_DIRTRIM=1 @@ -200,21 +198,24 @@ if [ -n "$PS1" ]; then fi gotcmd() { - command -v "$1" > /dev/null + command -v "$1" >/dev/null } if gotcmd zoxide; then - eval "$(zoxide init bash)" + eval "$(zoxide init bash)" fi if gotcmd starship; then - export PROMPT_COMMAND=prompt_set_window_title - eval "$(starship init bash)" + export PROMPT_COMMAND=prompt_set_window_title + eval "$(starship init bash)" else - export PROMPT_COMMAND=prompt_command + export PROMPT_COMMAND=prompt_command +fi + +if [ -e "$HOME/.cargo/env" ]; then + . "$HOME/.cargo/env" fi -if [ -e "$HOME/.cargo/env" ] -then - . "$HOME/.cargo/env" +if command -v pathdedup >/dev/null; then + export PATH="$(pathdedup)" fi -- cgit v1.2.1