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'")