mirror of
https://github.com/MillironX/dotfiles.git
synced 2024-12-04 01:59:55 +00:00
refactor: Replace shell path evaluation with Chezmoi evaluation
This commit is contained in:
parent
7319c73820
commit
1e8b917803
1 changed files with 9 additions and 18 deletions
|
@ -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
|
# Context-sensitive aliases
|
||||||
alias_if_exists bat batcat
|
{{- if lookPath "batcat" }}
|
||||||
alias_if_exists cat bat
|
alias bat=batcat
|
||||||
alias_if_exists ls lsd
|
{{- end }}
|
||||||
|
{{- if or (lookPath "bat") (lookPath "batcat") }}
|
||||||
|
alias cat=bat
|
||||||
|
{{- end }}
|
||||||
|
{{- if lookPath "lsd" }}
|
||||||
|
alias ls=lsd
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
# Universal aliases
|
# Universal aliases
|
||||||
alias config='git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
alias config='git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
||||||
|
|
Loading…
Reference in a new issue