Use templates and clean up loading of bash config
This commit is contained in:
parent
a25f59ba7f
commit
0250cbe9b0
2
dot_bash_profile
Normal file
2
dot_bash_profile
Normal file
@ -0,0 +1,2 @@
|
||||
. "${HOME}/.bashrc"
|
||||
# vim: filetype=bash
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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λ "
|
||||
44
dot_config/bash/prompt.sh.tmpl
Normal file
44
dot_config/bash/prompt.sh.tmpl
Normal file
@ -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 }}
|
||||
@ -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
|
||||
Loading…
Reference in New Issue
Block a user