diff --git a/dot_config/bash/bashrc.d/aliases.sh b/dot_config/bash/bashrc.d/aliases.sh.tmpl similarity index 68% rename from dot_config/bash/bashrc.d/aliases.sh rename to dot_config/bash/bashrc.d/aliases.sh.tmpl index ab2c47d..259924a 100644 --- a/dot_config/bash/bashrc.d/aliases.sh +++ b/dot_config/bash/bashrc.d/aliases.sh.tmpl @@ -18,11 +18,21 @@ alias wget-opendir='wget --recursive --level 0 --continue --no-clobber \ alias numfiles='find . -maxdepth 1 -type f | wc -l' alias take='sudo chown $(whoami):$(whoami) ' + +{{ if and (lookPath "jq") (lookPath "prettier") (lookPath "bat") -}} alias pretty_json='jq --compact-output | prettier --parser json | bat --language json' +{{- end }} + +{{ if eq .chezmoi.os "linux" -}} +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +{{- end }} + +{{ if lookPath "bat" -}} +alias batdiff='batdiff --pager=""' +alias cat=bat +{{- end }} -if [[ $(uname) == Linux ]]; then - alias ls='ls --color=auto' - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi +# vim: filetype=bash diff --git a/dot_config/bash/bashrc.d/bat.sh.tmpl b/dot_config/bash/bashrc.d/bat.sh.tmpl deleted file mode 100644 index 3ccf789..0000000 --- a/dot_config/bash/bashrc.d/bat.sh.tmpl +++ /dev/null @@ -1,9 +0,0 @@ -{{ if lookPath "bat" -}} -#!/usr/bin/env bash - -alias batdiff='batdiff --pager=""' - -if command -v bat &> /dev/null ; then - alias cat=bat -fi -{{- end }} diff --git a/dot_config/bash/bashrc.d/brew.sh.tmpl b/dot_config/bash/bashrc.d/brew.sh.tmpl deleted file mode 100644 index 6e30f1c..0000000 --- a/dot_config/bash/bashrc.d/brew.sh.tmpl +++ /dev/null @@ -1,8 +0,0 @@ -{{ if lookPath "brew" -}} -# vi: ft=bash -if command -v brew &> /dev/null; then - if [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then - . "$(brew --prefix)/share/bash-completion/bash_completion" - fi -fi -{{- end }} diff --git a/dot_config/bash/bashrc.d/completion.sh b/dot_config/bash/bashrc.d/completion.sh deleted file mode 100644 index 498ded4..0000000 --- a/dot_config/bash/bashrc.d/completion.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -# shellcheck disable=SC1091 -if [ -f /etc/bash_completion ]; then - source /etc/bash_completion -fi - -# shellcheck disable=SC1091 -if [ -f /usr/local/etc/bash_completion ]; then - source /usr/local/etc/bash_completion -fi - -COMPLETION_DIR=/usr/local/etc/bash_completion.d/ - -if [ -d "$COMPLETION_DIR" ]; then - # shellcheck disable=SC2045 - for i in $(ls "$COMPLETION_DIR"); do - file="$COMPLETION_DIR/$i" - if [ -r "${file}" ]; then - # shellcheck disable=SC1090 - source "${file}" - fi - unset file - done - unset i -fi - -unset COMPLETION_DIR diff --git a/dot_config/bash/bashrc.d/completion.sh.tmpl b/dot_config/bash/bashrc.d/completion.sh.tmpl new file mode 100644 index 0000000..94e6e87 --- /dev/null +++ b/dot_config/bash/bashrc.d/completion.sh.tmpl @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +{{ if stat "/etc/bash_completion" -}} +# shellcheck disable=SC1091 +source /etc/bash_completion +{{- end }} + +{{ if stat "/usr/local/etc/bash_completion" -}} +# shellcheck disable=SC1091 +source /usr/local/etc/bash_completion +{{- end }} + +{{ if stat "/usr/local/etc/bash_completion.d/" -}} +for i in $(ls /usr/local/etc/bash_completion.d/); do + if [ -r "/usr/local/etc/bash_completion.d/$i" ]; then + # shellcheck disable=SC1090 + source "/usr/local/etc/bash_completion.d/$i" + fi +done +unset i +{{- end }} + +{{ if lookPath "brew" -}} +# vi: ft=bash +if command -v brew &> /dev/null; then + if [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then + . "$(brew --prefix)/share/bash-completion/bash_completion" + fi +fi +{{- end }} + +{{ if lookPath "direnv" -}} +eval "$(direnv hook bash)" +{{- end }} + +{{ if lookPath "erd" -}} +eval "$(erd --completions bash)" +{{- end }} + +{{ if lookPath "helm" -}} +source <(helm completion bash) +{{- end }} + +{{ if lookPath "kubectl" -}} +source <(kubectl completion bash) +{{- end }} + +{{ if lookPath "starship" -}} +source <(starship init bash) +{{- end }} + +# vim: filetype=bash diff --git a/dot_config/bash/bashrc.d/direnv.sh.tmpl b/dot_config/bash/bashrc.d/direnv.sh.tmpl deleted file mode 100644 index 1b68945..0000000 --- a/dot_config/bash/bashrc.d/direnv.sh.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -{{ if lookPath "direnv" -}} -eval "$(direnv hook bash)" -{{- end }} diff --git a/dot_config/bash/bashrc.d/erdtree.sh.tmpl b/dot_config/bash/bashrc.d/erdtree.sh.tmpl deleted file mode 100644 index 9dc1041..0000000 --- a/dot_config/bash/bashrc.d/erdtree.sh.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -{{ if lookPath "erd" -}} -eval "$(erd --completions bash)" -{{- end }} diff --git a/dot_config/bash/bashrc.d/kubectl.sh.tmpl b/dot_config/bash/bashrc.d/kubectl.sh.tmpl deleted file mode 100644 index 453819e..0000000 --- a/dot_config/bash/bashrc.d/kubectl.sh.tmpl +++ /dev/null @@ -1,6 +0,0 @@ -{{ if lookPath "kubectl" -}} -# vi: ft=bash -if command -v kubectl > /dev/null 2>&1; then - source <(kubectl completion bash) -fi -{{- end }} diff --git a/dot_config/bash/bashrc.d/starship.sh.tmpl b/dot_config/bash/bashrc.d/starship.sh.tmpl deleted file mode 100644 index c569c46..0000000 --- a/dot_config/bash/bashrc.d/starship.sh.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -{{ if lookPath "starship" -}} -# vim: ft=bash -source <(starship init bash) -{{- end }} diff --git a/dot_config/profile/profile.d/go.sh.tmpl b/dot_config/profile/profile.d/go.sh.tmpl index 14233e7..c8dad4a 100644 --- a/dot_config/profile/profile.d/go.sh.tmpl +++ b/dot_config/profile/profile.d/go.sh.tmpl @@ -1,9 +1,9 @@ {{ if lookPath "go" -}} -__APPS_GO_PATH=/usr/local/apps/golang/current/bin -if [ -d "${__APPS_GO_PATH}" ] && ! echo "${PATH}" | grep -q ${__APPS_GO_PATH} ; then - PATH="$__APPS_GO_PATH:${PATH}" +{{ if stat "/usr/local/apps/golang/current/bin" -}} +if [ -d /usr/local/apps/golang/current/bin ] && ! echo "${PATH}" | grep -q /usr/local/apps/golang/current/bin ; then + PATH="/usr/local/apps/golang/current/bin:${PATH}" fi -unset __APPS_GO_PATH +{{- end }} if [ -d "${HOME}/go/bin" ] && ! echo "$PATH" | grep -q "${HOME}/go/bin" ; then PATH="${PATH}:${HOME}/go/bin"