Created
October 15, 2022 13:31
-
-
Save SmartFinn/8a62518b16242b9a78a7549a51646e48 to your computer and use it in GitHub Desktop.
Simple script that creates various directories to test your $LS_COLORS setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Simple script that creates various directories to test your $LS_COLORS setup | |
set -euo pipefail | |
mkdir -p test | |
cd test | |
# File | |
touch FILE | |
# Executable file | |
touch EXECUTABLE | |
chmod +x EXECUTABLE | |
# Symlink | |
ln -sf FILE SYMLINK | |
# Directory | |
mkdir -p DIRECTORY | |
# Directory symlink | |
[ -e DIRECTORY ] || ln -sf DIRECTORY DIR-SYMLINK | |
# Hardlink | |
touch HARDLINK1 | |
ln -f HARDLINK1 HARDLINK2 | |
# Create a link to nowhere | |
ln -sf nowhere ORPHAN | |
# World-writable | |
mkdir -p WORLDWRITEABLE | |
chmod o+w WORLDWRITEABLE | |
# Create a pipe | |
[ -e PIPE ] || mkfifo PIPE | |
# Create a block device driver | |
[ -e BLK ] || sudo mknod BLK b 1 8 | |
# Create a character device driver | |
[ -e CHR ] || sudo mknod CHR c 1 8 | |
# Create a file that is setuid | |
touch SETUID | |
chmod u+s SETUID | |
# Create a file that is setgid | |
touch SETGID | |
chmod g+s SETGID | |
# Directory with the sticky bit set | |
mkdir -p STICKY | |
chmod +t STICKY | |
# Directory that is other-writable | |
mkdir -p OTHER_WRITABLE | |
chmod o+w OTHER_WRITABLE | |
# Directory that is sticky and other-writable | |
mkdir -p STICKY_OTHER_WRITABLE | |
chmod +t,o+w STICKY_OTHER_WRITABLE | |
# Supported extensions | |
sed -e '/^$/d' -e '/^[^\.\*]/d' -e 's/^\([^ ]\+\).*/\1/' "$HOME/.dircolors" | | |
while read -r line; do | |
case "${line:0:1}" in | |
\*) | |
touch ./DIRECTORY/"${line#\*}" | |
;; | |
\.) | |
touch ./DIRECTORY/file"$line" | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment