Fixed omp prompt

Fixed: .envrc shows up when `direnv` does not exists
Fixed: history hook was running before _omp_hook, losing the latest
       error code.
This commit is contained in:
Gal@Shefet 2022-09-27 06:32:00 -04:00
parent d6687d8fa4
commit 09a810495f
6 changed files with 25 additions and 11 deletions

View File

@ -1,3 +1,13 @@
append_to_envvar() {
local __VAL_tmp_=$(eval "echo '$1'")
local __VAL_tmp_=$(echo "$__VAL_tmp_" | sed "s/${2}//" )
$1=$__VAL_tmp_${2}
}
insert_to_envvar() {
local __VAL_tmp_=$(eval "echo '$1'")
local __VAL_tmp_=$(echo "$__VAL_tmp_" | sed "s/${2}//" )
$1=${2}$__VAL_tmp_
}
get_clean_path() {
sed 's/ *:\?$//g;s/`/``/g;s/:/`:`/g;s/\\`:`/\\:/g;' <<< $1 | \
awk -v RS='`:`' -v ORS='`:`' '!arr[$0]++' | \

View File

@ -1,7 +1,7 @@
if [[ -n "$(which-command chezmoi)" ]]; then
export CHEZMOIROOT="$(chezmoi source-path)"
export CZ="$CHEZMOIROOT/_home"
export CZ_X="$CHEZMOIROOT/_externals"
export CZ="$CHEZMOIROOT"
export CZ_X="$(readlink -f $CHEZMOIROOT/../_externals)"
alias czcd="cd $CZ"
alias czxcd="cd $CZ_X"

View File

@ -1,6 +1,6 @@
if [[ -n "$(which-command oh-my-posh)" ]]; then
OHMYPOSH_CONFIG=''
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="~/.poshtheme.omp.json"
eval "$(oh-my-posh init bash --config $OHMYPOSH_CONFIG)"
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="--config ~/.poshtheme.omp.json"
eval "$(oh-my-posh init bash $OHMYPOSH_CONFIG)"
unset OHMYPOSH_CONFIG
fi

View File

@ -4,4 +4,5 @@ export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
[[ -z "$(printenv PROMPT_COMMAND | grep 'history -')" ]] && \
export PROMPT_COMMAND="$PROMPT_COMMAND; history -a; history -c; history -r"

View File

@ -1,4 +1,7 @@
alias which-command="type -fP "
function which-command() {
type -fP "${@}"
}
function add-alias-to-bash-completion-code() {
local CMD=$(printf "%s" "sed '" 's/\(complete\W.*-F\W.*' "$1" '.*$\)/\1 ' "$2/g'")

View File

@ -81,9 +81,9 @@
"style": "powerline",
"properties": {
"shell": "bash",
"command": "type -t direnv *>/dev/null && { direnv status *>&1 || true; } | grep \"Found RC allowed\"; true"
"command": "type -t direnv 2>/dev/null && { direnv status 2>&1 || true; } | grep \"Found RC allowed\"; true"
},
"template": "."
"template": "{{ if .Output }}.{{ end }}"
},
{
"type": "command",
@ -100,9 +100,9 @@
"trailing_diamond": "▓",
"properties": {
"shell": "bash",
"command": "type -t direnv *>/dev/null && { direnv status *>&1 || true; } | grep \"Found RC allowed\"; true"
"command": "type -t direnv 2>/dev/null && { direnv status 2>&1 || true; } | grep \"Found RC allowed\"; true"
},
"template": "envrc"
"template": "{{ if .Output }}envrc{{ end }}"
}
]
},
@ -281,7 +281,7 @@
"invert_powerline": true,
"powerline_symbol": "",
"properties": {
"always_enabled": true
"always_enabled": false
},
"style": "powerline",
"template": "{{ if gt .Code 0 }}{{ .Meaning }}{{ else }}✔{{ end }} ",
@ -333,7 +333,7 @@
"invert_powerline": true,
"style": "powerline",
"powerline_symbol": "",
"template": "sw{{ printf \"%.0f%%\" .SwapPercentUsed }}",
"template": "   {{ printf \"%.0f%%\" .SwapPercentUsed }}",
"type": "sysinfo"
},
{