Skip to content

Instantly share code, notes, and snippets.

@mbasaglia
Last active November 22, 2015 17:05
Show Gist options
  • Save mbasaglia/e5930afb09cf37b4010e to your computer and use it in GitHub Desktop.
Save mbasaglia/e5930afb09cf37b4010e to your computer and use it in GitHub Desktop.
Open and delete random file
#!/usr/bin/env bash
DIRECTORY="$PWD"
[ "$1" ] && DIRECTORY="$1"
selected="$(ls "$DIRECTORY" | sort -R | head -n 1)"
[ "$selected" ] || exit 1
xdg-open "$selected" && rm "$selected"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment