diff --git a/dot_bash_profile b/dot_bash_profile new file mode 100644 index 0000000..716afd1 --- /dev/null +++ b/dot_bash_profile @@ -0,0 +1,2 @@ +. "${HOME}/.bashrc" +# vim: filetype=bash diff --git a/dot_bashrc b/dot_bashrc.tmpl similarity index 89% rename from dot_bashrc rename to dot_bashrc.tmpl index 901ca16..9e35b6d 100644 --- a/dot_bashrc +++ b/dot_bashrc.tmpl @@ -2,16 +2,14 @@ # If not running interactively, don't do anything [ -z "$PS1" ] && return -if [[ ! $__PROFILE_LOADED__ ]]; then - . "${HOME}/.profile" -fi - -unset __PROFILE_LOADED__ +. "${HOME}/.profile" +{{ if not (lookPath "starship") -}} if [[ -f "${XDG_CONFIG_HOME}/bash/prompt.sh" ]]; then # shellcheck disable=SC1090 source "${XDG_CONFIG_HOME}/bash/prompt.sh" fi +{{- end }} if [ -d "${XDG_CONFIG_HOME}"/bash/bashrc.d ]; then for file in "${XDG_CONFIG_HOME}"/bash/bashrc.d/*.sh; do @@ -32,3 +30,5 @@ if [[ -d "${XDG_CONFIG_HOME}/bash/env.d" ]]; then )" done fi + +# vim: ft=bash diff --git a/dot_config/bash/bashrc.d/bash.sh b/dot_config/bash/bashrc.d/base.sh.tmpl similarity index 50% rename from dot_config/bash/bashrc.d/bash.sh rename to dot_config/bash/bashrc.d/base.sh.tmpl index df78a9a..a0c7127 100644 --- a/dot_config/bash/bashrc.d/bash.sh +++ b/dot_config/bash/bashrc.d/base.sh.tmpl @@ -1,24 +1,25 @@ #!/usr/bin/env bash -#ft=bash # always save bash history before showing prompt; allow reloading bashrc if [[ ! $PROMPT_COMMAND =~ "history -a" ]]; then PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" fi +{{ if and (lookPath "setxkbmap") (eq .chezmoi.os "linux") -}} # Disable capslock -if [[ -x $(which setxkbmap) ]] && [[ $(uname) == Linux ]]; then - setxkbmap -option ctrl:nocaps -fi +setxkbmap -option ctrl:nocaps +{{- end }} +{{ if lookPath "lesspipe" -}} # make less more friendly for non-text input files, see lesspipe(1) -if [ -x /usr/bin/lesspipe ]; then - eval "$(SHELL=/bin/sh lesspipe)" -fi +eval "$(SHELL=/bin/sh {{ lookPath "lesspipe" }})" +{{- end }} +{{ if lookPath "dircolors" -}} # enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - if test -r ~/.dircolors; then - eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - fi +if test -r ~/.dircolors; then + eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" fi +{{- end }} + +# vim: filetype=bash diff --git a/dot_config/bash/prompt.sh b/dot_config/bash/prompt.sh deleted file mode 100644 index c39aaa2..0000000 --- a/dot_config/bash/prompt.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z ${STARSHIP_SESSION_KEY} ]] ; then - return -fi - -color_off='\e[0m' -green='\e[0;32m' -yellow='\e[0;33m' -blue='\e[0;34m' -purple='\e[0;35m' -bblack='\e[1;30m' - -# display hostname -PS1="\[$green\]"'\u '"\[$blue\]"'$(hostname -s | tr ':A-Z:' ':a-z:') '"\[$green\]\w " - -if command -v git &> /dev/null ; then - parse_git_status () ( - if [[ $(git status 2> /dev/null | wc -l) -eq 0 ]]; then - return - fi - - if [[ $(git status 2> /dev/null | grep -c "working tree clean") -eq 0 ]]; then - echo ' ∓' - fi - ) - - parse_git_branch () ( - git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' - ) - # display git branch - PS1="$PS1\[$bblack\]"'$(parse_git_branch)' - # display git status - PS1="$PS1\[$yellow\]"'$(parse_git_status) ' -fi - -# display date -PS1="$PS1\[$purple\]\D{%F %I:%M%P} " -PS1="$PS1\[$color_off\]\nλ " diff --git a/dot_config/bash/prompt.sh.tmpl b/dot_config/bash/prompt.sh.tmpl new file mode 100644 index 0000000..9d15a24 --- /dev/null +++ b/dot_config/bash/prompt.sh.tmpl @@ -0,0 +1,44 @@ +{{ if not (lookPath "starship") -}} + +{{ if lookPath "git" -}} +_parse_git_status () ( + if [[ $(git status 2> /dev/null | wc -l) -eq 0 ]]; then + return + fi + + if [[ $(git status 2> /dev/null | grep -c "working tree clean") -eq 0 ]]; then + echo ' ∓' + fi +) + +_parse_git_branch () ( + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' +) +{{- end }} + +_create_prompt() ( + color_off='\e[0m' + green='\e[0;32m' + yellow='\e[0;33m' + blue='\e[0;34m' + purple='\e[0;35m' + bblack='\e[1;30m' + + + RET="\[$green\]"'\u '"\[$blue\]"'$(hostname -s | tr ':A-Z:' ':a-z:') '"\[$green\]\w " + {{ if lookPath "git" -}} + RET="$RET\[$bblack\]"'$(_parse_git_branch)' + RET="$RET\[$yellow\]"'$(_parse_git_status) ' + {{- end }} + + # display date + RET="$RET\[$purple\]\D{%F %I:%M%P} " + RET="$RET\[$color_off\]\nλ " + echo "$RET" +) + + +PS1=$(_create_prompt) + +# vim: ft=bash +{{- end }} diff --git a/dot_profile b/dot_profile.tmpl similarity index 64% rename from dot_profile rename to dot_profile.tmpl index 3433280..fd26420 100644 --- a/dot_profile +++ b/dot_profile.tmpl @@ -1,19 +1,18 @@ -#ft=sh - export LANGUAGE=en_US:en export LC_MESSAGES=en_US.UTF-8 export LC_CTYPE=en_US.UTF-8 export LC_COLLATE=en_US.UTF-8 -export XDG_BIN_HOME=${XDG_BIN_HOME:=$HOME/.local/bin} -export XDG_CACHE_HOME=${XDG_CACHE_HOME:=$HOME/.cache} +export XDG_BIN_HOME="${XDG_BIN_HOME:=$HOME/.local/bin}" +export XDG_CACHE_HOME="${XDG_CACHE_HOME:=$HOME/.cache}" export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:=/etc/xdg}" -export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:=$HOME/.config} -export XDG_DATA_DIRS=${XDG_DATA_DIRS:=/usr/local/share:/usr/share} -export XDG_DATA_HOME=${XDG_DATA_HOME:=$HOME/.local/share} -export XDG_INCLUDE_HOME=${XDG_INCLUDE_HOME:=$HOME/.local/include} -export XDG_STATE_HOME=${XDG_STATE_HOME:=$HOME/.local/state} +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:=$HOME/.config}" +export XDG_DATA_DIRS="${XDG_DATA_DIRS:=/usr/local/share:/usr/share}" +export XDG_DATA_HOME="${XDG_DATA_HOME:=$HOME/.local/share}" +export XDG_INCLUDE_HOME="${XDG_INCLUDE_HOME:=$HOME/.local/include}" +export XDG_STATE_HOME="${XDG_STATE_HOME:=$HOME/.local/state}" +{{- if eq .chezmoi.os "darwin" -}} if [ "${XDG_RUNTIME_DIR}" = "" ]; then __TMPDIR__= __LINK__=/tmp/$(id -u) @@ -28,6 +27,7 @@ if [ "${XDG_RUNTIME_DIR}" = "" ]; then fi export XDG_RUNTIME_DIR +{{- end }} env_file () { if [ ! -f "${1}" ]; then @@ -51,8 +51,6 @@ fi unset env_file -export __PROFILE_LOADED__=true - if [ -d "${XDG_CONFIG_HOME}/profile/profile.d" ]; then for file in "${XDG_CONFIG_HOME}"/profile/profile.d/*.sh; do if [ -r "$file" ]; then @@ -62,9 +60,4 @@ if [ -d "${XDG_CONFIG_HOME}/profile/profile.d" ]; then done fi -if [ "${BASH_VERSION}" != "" ] && [ "$(ps -p $$ -ocomm=)" != sh ]; then - # shellcheck disable=SC1090 - if [ -f "${HOME}/.bashrc" ]; then - . "${HOME}/.bashrc" - fi -fi +# vim: ft=sh diff --git a/dot_zshrc b/dot_zshrc index 4c622a8..83d063a 100644 --- a/dot_zshrc +++ b/dot_zshrc @@ -17,3 +17,5 @@ if [[ -d "${XDG_CONFIG_HOME}/zsh/zshrc.d" ]]; then fi done fi + +# vim: ft=zsh