Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
executable file 32 lines (28 sloc) 1.42 KB
# πŸ’»πŸ”€πŸ—‘οΈ Keep or Sweep
# Show a random file so you can clean your stuff
# Simply make executable and click (or run as bash
# Use the current folder for now, with optional argument for subfolder
# Get a random file, ignoring hidden files
# "tr -d '\0'" gets rid of "command substitution: ignored null byte in input"
RANDOMFILE=$(find "$FOLDER" -not -path '*/\.*' -type f -print0 | shuf -zn1 | tr -d '\0')
# Open file with relevant app, also checking for operating system
if [ "$(uname)" == "Darwin" ]; then
open "$RANDOMFILE" # macOS
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
xdg-open "$RANDOMFILE" # Linux
# Ask for Keep or Sweep
echo "Keep or Sweep $RANDOMFILE?"
select ks in "Keep" "Sweep"; do
case $ks in
Keep ) echo "βœ” KEPT $RANDOMFILE"; break;;
Sweep ) rm "$RANDOMFILE"; echo "❌ SWEPT $RANDOMFILE!"; exit;;