From 7c17b8922ce8ae97d21baf36973db8886013582e Mon Sep 17 00:00:00 2001 From: Lockszmith Date: Sun, 29 May 2022 05:33:04 +0000 Subject: [PATCH] Loading improvements .bashrc will skip .swp files (editors leave those while open) bin.path renamed to path.env and PATH manipulation should be 'cleaner' it adds required dirs to paths, but also makes sure no duplicates are inserted. chezmoi logic split, and status is seperated from aliases. Disable chezmoi status on load, as it is SLOW. --- _home/dot_bashrc | 2 +- _home/dot_sz.shrc.d/10_bin.path | 9 --------- _home/dot_sz.shrc.d/10_path.env | 18 ++++++++++++++++++ ..._keyboard_mappings => 91_keyboard_mappings} | 0 .../{98_chezmoi => 97_chezmoi_aliases} | 4 ---- _home/dot_sz.shrc.d/98_chezmoi_status.off | 5 +++++ 6 files changed, 24 insertions(+), 14 deletions(-) delete mode 100644 _home/dot_sz.shrc.d/10_bin.path create mode 100644 _home/dot_sz.shrc.d/10_path.env rename _home/dot_sz.shrc.d/{97_keyboard_mappings => 91_keyboard_mappings} (100%) rename _home/dot_sz.shrc.d/{98_chezmoi => 97_chezmoi_aliases} (82%) create mode 100644 _home/dot_sz.shrc.d/98_chezmoi_status.off diff --git a/_home/dot_bashrc b/_home/dot_bashrc index 12a3b54..baa6048 100644 --- a/_home/dot_bashrc +++ b/_home/dot_bashrc @@ -13,7 +13,7 @@ if [ -d ~/.sz.shrc.d ]; then script_source+=("$(find ~/.sz.shrc.d -maxdepth 0 -type d)") script_source+=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")") for script_src in ${script_source[@]}; do - scripts=$(find $script_src -maxdepth 1 -type f -not -name "*.off" | sort) + scripts=$(find $script_src -maxdepth 1 -type f -not -name "*.off" -not -name "*.swp" | sort) for script_name in $scripts; do if [ -r $script_name ]; then [ -z ${DBG_SZSHRC} ] || echo "Sourcing $script_name..." diff --git a/_home/dot_sz.shrc.d/10_bin.path b/_home/dot_sz.shrc.d/10_bin.path deleted file mode 100644 index d75f257..0000000 --- a/_home/dot_sz.shrc.d/10_bin.path +++ /dev/null @@ -1,9 +0,0 @@ -# set PATH so it includes user's private bin if it exists -if [[ -d "$HOME/bin" ]] ; then - export PATH="~/bin:$PATH" -fi - -# set PATH so it includes user's private bin if it exists -if [[ -d "$HOME/.local/bin" ]] ; then - export PATH="~/.local/bin:$PATH" -fi diff --git a/_home/dot_sz.shrc.d/10_path.env b/_home/dot_sz.shrc.d/10_path.env new file mode 100644 index 0000000..6f95470 --- /dev/null +++ b/_home/dot_sz.shrc.d/10_path.env @@ -0,0 +1,18 @@ +get_clean_path() { + sed 's/ *:\?$//g;s/`/``/g;s/:/`:`/g;s/\\`:`/\\:/g;' <<< $1 | \ + awk -v RS='`:`' -v ORS='`:`' '!arr[$0]++' | \ + sed 's/`:`/:/g;s/:$//g' +} + +# set PATH so it includes user's private bin if it exists +if [[ -d "$HOME/bin" ]] ; then + export PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [[ -d "$HOME/.local/bin" ]] ; then + export PATH="$HOME/.local/bin:$PATH" +fi + +PATH=$( get_clean_path $PATH ) + diff --git a/_home/dot_sz.shrc.d/97_keyboard_mappings b/_home/dot_sz.shrc.d/91_keyboard_mappings similarity index 100% rename from _home/dot_sz.shrc.d/97_keyboard_mappings rename to _home/dot_sz.shrc.d/91_keyboard_mappings diff --git a/_home/dot_sz.shrc.d/98_chezmoi b/_home/dot_sz.shrc.d/97_chezmoi_aliases similarity index 82% rename from _home/dot_sz.shrc.d/98_chezmoi rename to _home/dot_sz.shrc.d/97_chezmoi_aliases index 9affbc9..8828eb1 100644 --- a/_home/dot_sz.shrc.d/98_chezmoi +++ b/_home/dot_sz.shrc.d/97_chezmoi_aliases @@ -12,8 +12,4 @@ if [[ -n "$(type -fP chezmoi)" ]]; then chezmoi git -- remote set-url origin "$(chezmoi git -- remote get-url origin | sed 's|git@github.com:|https://github.com/|')" chezmoi git -- remote get-url origin } - - CHEZMOI_OUT="$(chezmoi status || true)x" - [[ "x" != "$CHEZMOI_OUT" ]] && printf "\nChezmoi changes:\n" && echo "${CHEZMOI_OUT%?}" - unset CHEZMOI_OUT fi diff --git a/_home/dot_sz.shrc.d/98_chezmoi_status.off b/_home/dot_sz.shrc.d/98_chezmoi_status.off new file mode 100644 index 0000000..17106ec --- /dev/null +++ b/_home/dot_sz.shrc.d/98_chezmoi_status.off @@ -0,0 +1,5 @@ +if [[ -n "$(type -fP chezmoi)" ]]; then + CHEZMOI_OUT="$(chezmoi status || true)x" + [[ "x" != "$CHEZMOI_OUT" ]] && printf "\nChezmoi changes:\n" && echo "${CHEZMOI_OUT%?}" + unset CHEZMOI_OUT +fi