From 1e8b917803e053e955628b4df02adec49b26ad0b Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Sat, 15 Apr 2023 17:16:40 -0500 Subject: [PATCH] refactor: Replace shell path evaluation with Chezmoi evaluation --- dot_aliases.tmpl | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/dot_aliases.tmpl b/dot_aliases.tmpl index 6448c8f..89e6d7e 100644 --- a/dot_aliases.tmpl +++ b/dot_aliases.tmpl @@ -1,22 +1,13 @@ -# Only create aliases if the underlying programs are available -# This allows portability between machines in different states -alias_if_exists () { - ALIAS=${1} - COMMAND=${2} - ARGS=${3} - if [ $(command -v $COMMAND) ]; then - if [ -n "$ARGS" ]; then - alias $ALIAS="$COMMAND $ARGS" - else - alias $ALIAS="$COMMAND" - fi - fi -} - # Context-sensitive aliases -alias_if_exists bat batcat -alias_if_exists cat bat -alias_if_exists ls lsd +{{- if lookPath "batcat" }} +alias bat=batcat +{{- end }} +{{- if or (lookPath "bat") (lookPath "batcat") }} +alias cat=bat +{{- end }} +{{- if lookPath "lsd" }} +alias ls=lsd +{{- end }} # Universal aliases alias config='git --git-dir=$HOME/.cfg/ --work-tree=$HOME'