Taylor Beseda

Web Engineering Enthusiast

Colorado Front Range
DevEx Engineer at Begin.com.


gitclean zsh command ๐Ÿ”—

Edited:
gitclean() {
  git clean -Xdn
  if read -q REPLY\?"Clean these? (Y/y)"; then
    git clean -Xdf
  else
    echo "Still dirty."
  fi
}

For more fancy, use โ€œgumโ€:

gitclean() {
  DIRTY=$(git clean -Xdn | sed 's/Would remove //g')

  gum style \
    --foreground 196 --border thick --border-foreground 88 \
    --margin "1 2" --padding "1 3" "$DIRTY"

  gum confirm "๐Ÿงน Delete these?" \
    && git clean -Xdf \
    || echo "Still dirty."
}

gum docs gist version with preview image