Attempt aligning bash with zsh

- support PROMPT
- support RPROMPT (buggy if on same line)
- support zsh color codes in PROMPT and RPROMPT
- refactor set_prompt to use PROMPT and RPROMPT
- add duration and rc to RPROMPT
This commit is contained in:
Loic Nageleisen 2023-04-20 15:29:49 +02:00
parent 3c3b89831b
commit bbd976f569
Signed by: lloeki
GPG key ID: D05DAEE6889F94C2
3 changed files with 95 additions and 22 deletions

16
bash/rc
View file

@ -19,14 +19,28 @@ GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
precmd() {
LAST_CMD_RC=$?
CMD_RC=$?
if [[ -n ${CMD_START} ]]; then
CMD_END="${EPOCHREALTIME}"
CMD_DURATION=$(bc <<<"${CMD_END} - ${CMD_START}")
unset CMD_START
unset CMD_END
fi
_direnv_hook
#clear_incomplete_line
set_prompt
apply_prompt_rprompt
update_terminal_cwd
set_term_title
}
preexec() {
set_term_title
CMD_START="${EPOCHREALTIME}"
}
chpwd() {
__git_ps1_gitdir
_gopath