Last active
January 25, 2022 18:31
-
-
Save ixti/4b4bf7dbce807f977484fc9a04b9d703 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
if [ -n "$1" ] && [ -n "$2" ]; then | |
LS_COLORS="$(vivid --database "$1" generate "$2")" | |
elif [ -n "$1" ]; then | |
LS_COLORS="$(vivid generate "$1")" | |
else | |
echo "USAGE: $0 [database] theme" >&2 | |
exit 1 | |
fi | |
export LS_COLORS | |
ORIG_DIR="$(pwd)" | |
TEST_DIR="${ORIG_DIR}/vivid-test-files" | |
cleanup() { | |
cd "${ORIG_DIR}" || cd || exit 1 | |
rm -rf "${TEST_DIR}" | |
pkill --parent $$ | |
} | |
trap cleanup EXIT | |
generate() { | |
rm -rf "${TEST_DIR}" | |
mkdir --parents "${TEST_DIR}" | |
mkdir --parents "${TEST_DIR}/core/directory" | |
touch "${TEST_DIR}/core/regular_file" | |
touch "${TEST_DIR}/core/file_with_capability" | |
sudo setcap cap_dac_read_search+ep "${TEST_DIR}/core/file_with_capability" | |
mkfifo "${TEST_DIR}/core/fifo" | |
ln -s "regular_file" "${TEST_DIR}/core/symlink" | |
touch "${TEST_DIR}/core/multi_hard_link" | |
ln "${TEST_DIR}/core/multi_hard_link" "${TEST_DIR}/core/multi_hard_link-2" | |
ln -s "missing_symlink_target" "${TEST_DIR}/core/broken_symlink" | |
touch "${TEST_DIR}/core/setuid" | |
chmod 04644 "${TEST_DIR}/core/setuid" | |
touch "${TEST_DIR}/core/setgid" | |
chmod 02644 "${TEST_DIR}/core/setgid" | |
touch "${TEST_DIR}/core/other_writable" | |
chmod 0666 "${TEST_DIR}/core/other_writable" | |
touch "${TEST_DIR}/core/executable_file" | |
chmod 0755 "${TEST_DIR}/core/executable_file" | |
mkdir "${TEST_DIR}/core/sticky_other_writable" | |
chmod 01777 "${TEST_DIR}/core/sticky_other_writable" | |
mkdir "${TEST_DIR}/core/sticky" | |
chmod 01755 "${TEST_DIR}/core/sticky" | |
nc -lkU "${TEST_DIR}/core/socket" & | |
for filename in \ | |
text/special/{AUTHORS,CHANGES,CONTRIBUTORS,CONTRIBUTORS.md,CONTRIBUTORS.txt,HISTORY,INSTALL,INSTALL.md,INSTALL.txt,README,README.md,README.rst,README.txt} \ | |
text/todo/{TODO,TODO.md,TODO.txt} \ | |
text/licenses/{COPYING,COPYRIGHT,LICENSE,LICENSE-APACHE,LICENSE-MIT} \ | |
text/configuration/generic/example{.cfg,.conf,.config,.ini,.json,.tml,.toml,.yaml,.yml} \ | |
text/configuration/metadata/example.xmp \ | |
text/configuration/bibtex/example{.bib,.bst} \ | |
text/configuration/dockerfile/{Containerfile,Dockerfile} \ | |
text/configuration/nix/example.nix \ | |
text/configuration/qt/example.ui \ | |
text/configuration/desktop/example.desktop \ | |
text/configuration/system/{passwd,shadow} \ | |
text/other/example.txt \ | |
markup/web/example{.htm,.html,.shtml,.xhtml} \ | |
markup/other/example{.csv,.markdown,.md,.mdown,.rst,.xml} \ | |
programming/source/actionscript/example.as \ | |
programming/source/applescript/example.applescript \ | |
programming/source/asp/example.asa \ | |
programming/source/awk/example.awk \ | |
programming/source/basic/example.vb \ | |
programming/source/cabal/example.cabal \ | |
programming/source/clojure/example.clj \ | |
programming/source/crystal/example.cr \ | |
programming/source/csharp/example{.cs,.csx} \ | |
programming/source/css/css \ | |
programming/source/cxx/example{.c,.cpp,.cc,.cp,.cxx,.c++,.h,.hh,.hpp,.hxx,.h++,.inc,.inl,.ipp,.def} \ | |
programming/source/d/example{.d,.di} \ | |
programming/source/dart/example.dart \ | |
programming/source/diff/example{.diff,.patch} \ | |
programming/source/elixir/example{.ex,.exs} \ | |
programming/source/elm/example.elm \ | |
programming/source/erlang/example.erl \ | |
programming/source/fsharp/example{.fs,.fsi,.fsx} \ | |
programming/source/go/example.go \ | |
programming/source/graphviz/example{.dot,.gv} \ | |
programming/source/groovy/example{.groovy,.gvy,.gradle} \ | |
programming/source/haskell/example.hs \ | |
programming/source/ipython/example.ipynb \ | |
programming/source/java/example{.java,.bsh} \ | |
programming/source/javascript/example{.js,.htc} \ | |
programming/source/julia/example.jl \ | |
programming/source/kotlin/example{.kt,.kts} \ | |
programming/source/latex/example{.tex,.ltx} \ | |
programming/source/less/example.less \ | |
programming/source/llvm/example{.ll,.mir} \ | |
programming/source/lisp/example{.lisp,.el} \ | |
programming/source/lua/example.lua \ | |
programming/source/mathematica/example.nb \ | |
programming/source/matlab/example{.matlab,.m,.mn} \ | |
programming/source/ocaml/example{.ml,.mli} \ | |
programming/source/pascal/example{.pas,.p,.dpr} \ | |
programming/source/perl/example{.pl,.pm,.pod,.t,.cgi} \ | |
programming/source/php/example.php \ | |
programming/source/powershell/example{.ps1,.psm1,.psd1} \ | |
programming/source/puppet/example{.pp,.epp} \ | |
programming/source/purescript/example.purs \ | |
programming/source/python/example.py \ | |
programming/source/r/example.r \ | |
programming/source/ruby/example.rb \ | |
programming/source/rust/example.rs \ | |
programming/source/scala/example{.scala,.sbt} \ | |
programming/source/shell/example{.sh,.bash,.zsh,.fish} \ | |
programming/source/sql/example.sql \ | |
programming/source/swift/example.swift \ | |
programming/source/tablegen/example.td \ | |
programming/source/tcl/example.tcl \ | |
programming/source/typescript/example{.ts,.tsx} \ | |
programming/source/viml/example.vim \ | |
programming/tooling/vcs/git/example{.gitignore,.gitmodules,.gitattributes,.gitconfig} \ | |
programming/tooling/vcs/hg/hgrc programming/tooling/vcs/hg/example.hgrc \ | |
programming/tooling/vcs/other/CODEOWNERS programming/tooling/vcs/other/example{.ignore,.fdignore,.rgignore} \ | |
programming/tooling/build/cmake/CMakeLists.txt programming/tooling/build/cmake/example{.cmake,.cmake.in} \ | |
programming/tooling/build/make/Makefile programming/tooling/build/make/example.make \ | |
programming/tooling/build/automake/Makefile.am \ | |
programming/tooling/build/configure/{configure,configure.ac} \ | |
programming/tooling/build/scons/{SConscript,SConstruct} \ | |
programming/tooling/build/pip/requirements.txt \ | |
programming/tooling/packaging/python/{MANIFEST.in,setup.py} \ | |
programming/tooling/packaging/ruby/example.gemspec \ | |
programming/tooling/code-style/python/example.flake8 \ | |
programming/tooling/code-style/cxx/example.clang-format \ | |
programming/tooling/editors/qt/example.pro \ | |
programming/tooling/editors/kdevelop/example.kdevelop \ | |
programming/tooling/documentation/doxygen/Doxyfile programming/tooling/documentation/doxygen/example.dox \ | |
programming/tooling/continuous-integration/appveyor.yml programming/tooling/continuous-integration/example.travis.yml \ | |
media/image/example{.bmp,.eps,.gif,.ico,.jpeg,.jpg,.pbm,.pgm,.png,.ppm,.psd,.svg,.tif,.tiff,.xcf} \ | |
media/audio/example{.aif,.flac,.m4a,.mid,.mp3,.ogg,.opus,.wav,.wma,.wv} \ | |
media/video/example{.avi,.flv,.h264,.m4v,.mkv,.mov,.mp4,.mpeg,.mpg,.rm,.swf,.vob,.webm,.wmv} \ | |
media/fonts/example{.fnt,.fon,.otf,.ttf} \ | |
office/document/example{.doc,.docx,.epub,.odt,.pdf,.ps,.rtf,.sxw} \ | |
office/spreadsheet/example{.xls,.xlsx,.ods,.xlr} \ | |
office/presentation/example{.ppt,.pptx,.odp,.sxi,.kex,.pps} \ | |
office/calendar/example.ics \ | |
archives/packages/example{.apk,.deb,.rpm} \ | |
archives/ros/example.bag \ | |
archives/images/example{.bin,.dmg,.img,.iso,.toast,.vcd} \ | |
archives/other/example{.7z,.arj,.bz,.bz2,.gz,.jar,.pkg,.rar,.tar,.tbz,.tbz2,.tgz,.xz,.z,.zip,.zst} \ | |
executable/windows/example{.bat,.com,.exe} \ | |
executable/library/example{.so,.a,.dll} \ | |
executable/linux/example.ko \ | |
unimportant/build_artifacts/cxx/example{.o,.la,.lo} \ | |
unimportant/build_artifacts/cmake/CMakeCache.txt \ | |
unimportant/build_artifacts/automake/Makefile.in \ | |
unimportant/build_artifacts/rust/example.rlib \ | |
unimportant/build_artifacts/python/example{.pyc,.pyd,.pyo} \ | |
unimportant/build_artifacts/haskell/example{.dyn_hi,.dyn_o,.cache,.hi} \ | |
unimportant/build_artifacts/java/example.class \ | |
unimportant/build_artifacts/scons/example{.scons_opt,.sconsign.dblite} \ | |
unimportant/build_artifacts/latex/example{.aux,.bbl,.bcf,.blg,.fdb_latexmk,.fls,.idx,.ilg,.ind,.out,.sty,.synctex.gz,.toc} \ | |
unimportant/build_artifacts/llvm/example.bc \ | |
unimportant/macos/example{.CFUserTextEncoding,.DS_Store,.localized} \ | |
unimportant/other/{~,package-lock.json} unimportant/other/example{.bak,.git,.lock,.log,.orig,.pid,.swp,.tmp} | |
do | |
mkdir --parents "${TEST_DIR}/$(dirname "${filename}")" | |
touch "${TEST_DIR}/${filename}" | |
done | |
} | |
generate | |
cd "${TEST_DIR}" || exit 1 | |
# character_device: /dev/tty | |
# block_device: /dev/nvme0n1 | |
ls -l --color=always core /dev/tty0 /dev/nvme0n1 | |
find archives executable markup media office programming text unimportant -type f \ | |
| sort \ | |
| xargs ls --color=always |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment