Use templates and clean up loading of bash config
parent
a25f59ba7f
commit
0250cbe9b0
@ -0,0 +1,2 @@
|
|||||||
|
. "${HOME}/.bashrc"
|
||||||
|
# vim: filetype=bash
|
@ -1,24 +1,25 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#ft=bash
|
|
||||||
|
|
||||||
# always save bash history before showing prompt; allow reloading bashrc
|
# always save bash history before showing prompt; allow reloading bashrc
|
||||||
if [[ ! $PROMPT_COMMAND =~ "history -a" ]]; then
|
if [[ ! $PROMPT_COMMAND =~ "history -a" ]]; then
|
||||||
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{{ if and (lookPath "setxkbmap") (eq .chezmoi.os "linux") -}}
|
||||||
# Disable capslock
|
# Disable capslock
|
||||||
if [[ -x $(which setxkbmap) ]] && [[ $(uname) == Linux ]]; then
|
setxkbmap -option ctrl:nocaps
|
||||||
setxkbmap -option ctrl:nocaps
|
{{- end }}
|
||||||
fi
|
|
||||||
|
|
||||||
|
{{ if lookPath "lesspipe" -}}
|
||||||
# make less more friendly for non-text input files, see lesspipe(1)
|
# make less more friendly for non-text input files, see lesspipe(1)
|
||||||
if [ -x /usr/bin/lesspipe ]; then
|
eval "$(SHELL=/bin/sh {{ lookPath "lesspipe" }})"
|
||||||
eval "$(SHELL=/bin/sh lesspipe)"
|
{{- end }}
|
||||||
fi
|
|
||||||
|
|
||||||
|
{{ if lookPath "dircolors" -}}
|
||||||
# enable color support of ls and also add handy aliases
|
# enable color support of ls and also add handy aliases
|
||||||
if [ -x /usr/bin/dircolors ]; then
|
if test -r ~/.dircolors; then
|
||||||
if test -r ~/.dircolors; then
|
|
||||||
eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||||
fi
|
|
||||||
fi
|
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λ "
|
|
@ -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 }}
|
Loading…
Reference in New Issue