4 Incheckningar d93c50d816 ... f0a7d12e97

Upphovsman SHA1 Meddelande Datum
  Kyle P Davis f0a7d12e97 feat: alias vim to nvim if available 6 månader sedan
  Kyle P Davis e6e5a05ca9 feat: auto notify if dotfiles is outdated 6 månader sedan
  Kyle P Davis 1a46afeb8d feat: prefer mise shims for dev tools if available 6 månader sedan
  Kyle P Davis b67052263c fix: avoid error if no extra user python dirs 6 månader sedan
1 ändrade filer med 23 tillägg och 1 borttagningar
  1. 23 1
      .profile

+ 23 - 1
.profile

@@ -19,7 +19,8 @@ OS=$(uname -s)
 export PATH="$PATH:$HOME/.local/bin:$HOME/bin"
 
 # Setup user-specific Python overrides
-if [ "$OS" = "Darwin" ]; then
+_PY_BASE_DIR="$HOME/Library/Python/";
+if [ "$OS" = "Darwin" ] && [ -d "$_PY_BASE_DIR" ]; then
 	for PY_DIR in "$HOME/Library/Python/"*/; do
 		export PATH="$PY_DIR/bin:$PATH"
 	done
@@ -77,6 +78,26 @@ else
 	setopt HIST_IGNORE_SPACE # ignore if leading space
 fi
 
+# Auto fetch and ask to pull if outdated once every 30 days
+DOTFILES_DIR="$HOME/.dotfiles"
+DOTFILES_GIT_DIR="$DOTFILES_DIR/.git"
+DOTFILES_GIT_FETCH_HEAD_PATH="$DOTFILES_GIT_DIR/FETCH_HEAD"
+DOTFILES_CHECK_DAYS=30
+if [ -d "$DOTFILES_GIT_DIR" ] && [ $(( $(date +%s) - $(date -r "$DOTFILES_GIT_FETCH_HEAD_PATH" +%s) )) -gt $(( $DOTFILES_CHECK_DAYS * 24 * 60 * 60 )) ]; then
+	# auto fetch repo
+	git -C "$DOTFILES_DIR" fetch || :
+	# complain if branch is outdated and ask to update
+	COMMITS_BEHIND=$(git -C "$DOTFILES_DIR" rev-list --count HEAD..@{u})
+	if [ "$COMMITS_BEHIND" -gt 0 ]; then
+		echo "😅 Outdated dotfiles repo!"
+		echo "🧐   Review via:  git -C \"\$DOTFILES_DIR\" log HEAD..@{u} --oneline --reverse"
+		echo "👍   Update via:  git -C \"\$DOTFILES_DIR\" pull"
+	fi
+fi
+
+# Enable auto-switching by adding mise-aware tool shims to PATH (which resolves tool versions lazily and avoids issues caused by other approaches)
+! has_bin mise  ||  export PATH="$HOME/.local/share/mise/shims:$PATH"
+
 # Custom shell aliases
 if [ "$OS" = "Darwin" ]; then
 	export CLICOLOR=1
@@ -93,6 +114,7 @@ alias tree="tree -C -F"
 alias grep="grep --color"
 alias man='LESS_TERMCAP_md=$(tput bold && tput setaf 4 || :) LESS_TERMCAP_me=$(tput sgr0 || :) LESS_TERMCAP_mb=$(tput blink || :) LESS_TERMCAP_us=$(tput setaf 2 || :) LESS_TERMCAP_ue=$(tput sgr0 || :) LESS_TERMCAP_so=$(tput smso || :) LESS_TERMCAP_se=$(tput rmso || :) PAGER="${commands[less]:-$PAGER}" man'
 alias vi=vim
+! has_bin nvim  ||  alias vim=nvim
 
 # aliases for node
 alias node-print="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx=require(fs.existsSync(f)?path.resolve(f):f); eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(console.log,e=>{console.error(e);process.exit(1)})'"