diff --git a/bash/bash_aliases b/bash/bash_aliases index bf8552a0c..874ee2207 100644 --- a/bash/bash_aliases +++ b/bash/bash_aliases @@ -51,6 +51,9 @@ alias mpv="flatpak run io.mpv.Mpv" # Detect if I'm in a toolbox alias isdistrobox='[ -f "/run/.toolboxenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv' +# Flag that the directory was just changed (used with prompt) +alias cd='export DIRCHANGED="1"; cd' + if [ $(isdistrobox) ]; then source $HOME/.dotfiles/bash/bash_aliases.distrobox else diff --git a/bash/prompt.sh b/bash/prompt.sh index c765fdee1..bc4c1752e 100755 --- a/bash/prompt.sh +++ b/bash/prompt.sh @@ -9,6 +9,14 @@ elif [[ $ARG != '' ]]; then exit 0 fi +# If directory was just changed to the root of a git repository, print onefetch +if [ ! -z $DIRCHANGED ]; then + if [ -d $PWD/.git ]; then + $HOME/bin/onefetch + fi + unset DIRCHANGED +fi + # Default colours # 0 default, 1 red 2 green 3 yellow 4 blue 5 magenta 6 cyan 7 white (grey) PC="0" # prompt default