Skip to content
Permalink
Browse files

Add first version of bash script

Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
  • Loading branch information...
jancborchardt committed Mar 23, 2018
1 parent 917edc6 commit 079d88e34e1578a46981aa575011a826da0b006c
Showing with 26 additions and 0 deletions.
  1. +26 βˆ’0 random-declutter.sh
@@ -0,0 +1,26 @@
#!/bin/bash
# πŸ’»πŸ”€πŸ—‘οΈ Random declutter
# Show a random file so you can clean your stuff
# Simply make executable and click (or run as bash random-declutter.sh)
# Jan-Christoph Borchardt, http://jancborchardt.net

# Use the current folder
FOLDER=$(pwd)

# Get a random file
# "tr -d '\0'" gets rid of "command substitution: ignored null byte in input"
RANDOMFILE=$(find "$FOLDER" -type f -print0 | shuf -zn1 | tr -d '\0')

# Find the filetype and isolate it
FILETYPE=$(file --mime-type "$RANDOMFILE" | cut -d ":" -f2-)

# Open file with relevant app
if [[ "$FILETYPE" = *"image"* ]]; then
eog "$RANDOMFILE"
elif [[ "$FILETYPE" = *"pdf"* ]]; then
evince "$RANDOMFILE"
elif [[ "$FILETYPE" = *"text"* ]]; then
gedit "$RANDOMFILE"
else
echo "$FILETYPE not supported yet"
fi

0 comments on commit 079d88e

Please sign in to comment.
You can’t perform that action at this time.