~~~ 1 ├── filesystem │   ├── collect-file │   ├── delete-broken-links │   ├── delete-empty-files │   ├── fig │   ├── find-leaf-directories │   ├── find-recently-changed │   ├── full-path │   ├── group │   ├── is-empty-directory │   ├── late-write │   ├── list-broken-symlinks │   ├── mount-home │   ├── mvup │   ├── path-directories │   ├── path-permissions │   ├── search │   ├── searchl │   └── splice ├── other │   ├── git-log │   ├── nargs │   ├── nargsp │   ├── repl │   ├── repl-stdin │   ├── restart-on-end │   └── with-dialog-and-delay ├── text │   ├── comma-to-newline │   ├── comma-to-space │   ├── compress-newlines │   ├── compress-spaces │   ├── file-lines-set-operations │   ├── generate-password │   ├── lines-filter │   ├── lines-reject │   ├── lowercase │   ├── newline-to-comma │   ├── newline-to-space │   └── space-to-newline └── time ├── day-seconds ├── hms-time ├── iso-date ├── iso-week-number ├── posixtime ├── posixtime-to-date ├── tzdate └── year-week-count 2 ├── convert │   ├── binary │   ├── freemind2indent │   ├── hex │   ├── indent2freemind │   ├── sxml2xml │   └── xml2sxml ├── filesystem │   ├── clone-disk │   ├── create-filelist │   ├── delete-duplicate-files │   ├── fig-full │   ├── file-size-sum │   ├── find-by-md5sum │   ├── format-encrypt │   ├── get-unique-path │   ├── gui-group │   ├── hardlink-to-copy │   ├── list-file-size │   ├── merge-files │   ├── move-and-link │   ├── name-add-date │   ├── prefix-sort │   ├── prepend-date │   ├── prepend-media-bitrate │   ├── prepend-to-filename │   ├── remove-extension │   ├── rename-lowercase │   ├── set-permissions │   ├── splice-if-single │   └── tidyfiles ├── media │   ├── aac2wav │   ├── audio-file-loudness │   ├── get-audio-disc-files │   ├── get-photos │   ├── media-info-json │   ├── media-info-video-bitrate │   ├── normalize-volume │   ├── pdf2images │   ├── prepend-image-size │   ├── prepend-video-tags │   ├── remove-video-tags │   ├── sacd2dsf │   ├── scale-images │   ├── show-video-thumbnails-image │   ├── split-flac-cue │   ├── stereoscopy │   │   ├── create-anaglyph-image │   │   ├── gopro3-stereo-merge │   │   ├── merge-stereo-images │   │   ├── merge-stereo-videos │   │   ├── split-stereo-images │   │   └── split-stereo-video │   ├── video-extract-audio │   ├── video-extract-frames │   ├── video-from-png-images │   ├── video-thumbnails-image │   ├── video-thumbnails-images │   ├── wav32-to-flac │   └── youtube-dl-with-date ├── other │   ├── backup │   ├── cpioc │   ├── cpioe │   ├── dwm-show-info │   ├── e │   ├── emacs-open-in-background │   ├── first │   ├── g │   ├── git-create-stable-branch │   ├── git-log-short │   ├── git-merge-stable-master │   ├── git-push │   ├── git-stati │   ├── golden-ratio │   ├── gui-emacs │   ├── gui-md5sum │   ├── gui-scale-images │   ├── hide-stderr │   ├── http-status │   ├── ldd-list-not-found │   ├── man-echo │   ├── mariadb-create-user-database-sql │   ├── nargs-all │   ├── rest │   ├── show-process-memory-usage-top │   ├── ssh-install-key │   ├── statistics │   ├── take-screenshot │   ├── take-screenshots-in-intervals │   └── take-screenshot-window ├── programming │   ├── astyle-to-file │   ├── c-format │   ├── coffee-compile │   ├── coffee-compile-from-to │   ├── compress-js │   ├── guile-display-documentation │   ├── guile-module-dependencies │   ├── javascript-remove-semicolons │   ├── json-to-file │   ├── lines-to-quoted-comma-lines │   ├── lines-to-scheme-data │   ├── scm-format │   ├── sql-format │   ├── wisp2lisp │   ├── xml-format │   └── xml-json-converter ├── text │   ├── alternate-text-direction │   ├── body │   ├── camelcase-to-dash │   ├── camelcase-to-underscore │   ├── decapitalize │   ├── drop-long-lines │   ├── first-space-to-semicolon │   ├── itpn │   ├── itpn-split │   ├── lines-append │   ├── lines-enclose │   ├── randomize-lines │   ├── remove-hash-comment-lines │   ├── remove-iso-date-prefix-zeros │   ├── remove-semicolon-comment-lines │   ├── split-select │   ├── string-base16 │   ├── string-base32 │   ├── string-binary │   └── sum-numbers └── time ├── d ├── hms-to-ks ├── hms-to-minutes ├── hours-and-minutes-till-midnight ├── ks-time ├── ks-to-hms ├── uptime-duration-ks └── uptime-start-ks 16 directories, 175 files ~~~ scripts in `1` are generally more useful and scripts in `2` are more experimental. # dependencies primarily posix shell (/bin/sh). the goal is to prefer posix shell, and use coreutils and bsd compatible commands. tools are currently preferred in this order: shell, tr, sed, ruby. however, some scripts currently still have other dependencies, for example on [guile](https://www.gnu.org/software/guile/). # installation assuming that "$HOME/exe" is listed in the $PATH environment variable (which it is not by default), you can use the following to symlink all scripts into the path (uses the gnu version of cp): ~~~ cd sph-script cp -st $HOME/exe $PWD/{1,2}/*/* ~~~ you can add paths to the $PATH environment variable for example in "/etc/profile" like this: ~~~ export PATH="$PATH:$HOME/exe" ~~~ which would mean that you can put scripts in a directory named "exe" in your home directory and they should be found as commands on the command-line. # documentation ## filesystem ### collect-file symlink or copies all given source-paths into an automatically chosen target directory. one use case is browsing files with a file manager and using right-click actions to collect specific files ### delete-empty-files delete broken links in the given directory or current directory and sub-directories ### delete-broken-symlinks delete broken symlinks in the given directory or current directory and sub-directories ### fig find files containing all argument strings in the name. the name is a combination of find and grep list all paths under the current working directory that contain all (default) of the given search strings. excludes the directories node_modules/.git/cache/vendor. ~~~ arguments: [lines-filter-options ...] search-string ... ~~~ ~~~ fig test1 test2 ~~~ depends on [ripgrep](https://github.com/BurntSushi/ripgrep) ### full-path display the full path that starts from the root directory for a given path ### late-write write to output file only after all data from standard input has been read. allows to overwrite source files when using shell output redirection. ~~~ arguments: output_file ~~~ #### example ~~~ cat testfile | newline-to-space | late-write testfile ~~~ testfile is not truncated but updated with the expected results. be careful: do not use ">" out of habit. ">" *always* truncates, late-write only takes simple pipe input with "|" ### list-broken-symlinks list broken symlinks in the current directory ### mount-home * mount filesystems to automatically chosen paths under ~/mnt * mount filesystems to $HOME/mnt/{last-part-of-source} #### examples $ mount-home /dev/sdd1 mounts the filesystem to /home/username/mnt/dev/sdd1 $ mount-home -s -l label1 label2 mounts with sudo and by partition label #### benefits * paths are automatically chosen * paths are automatically created * paths are predictable * mount multiple sources in one call #### command-line interface mount filesystems to $HOME/mnt/{source_basename_or_label} benefits: mount paths are automatically chosen, mount paths are predictable, and multiple sources can be mounted in one call. $ mount-home ~~~ arguments: [options] source ... options: -s use sudo, -l interpret sources as disk labels mount directory: $HOME/mnt ~~~ ### nargs, nargsp, nargs-all * pass each newline separated line read from standard-input as an argument to a command * equivalent to "xargs -n 1 -d \n" * "nargsp" executes commands in parallel * "nargs-all" passes all arguments at once ### mvup move given files into their parent directories, unless a file with the same name already exists there. if the "-n" option for the count of parent directories to skip is given, it must be the first argument; the default is 1. ~~~ usage: [-n integer] file ... ~~~ ### path-directories lists all parent directories #### example path-directories $PWD ~~~ /srv/http/test /srv/http /srv ~~~ ### path-permissions like "path-directories" but also displays permissions in octal notation #### example path-permissions $PWD ~~~ 700 /srv/http/test 700 /srv/http 700 /srv ~~~ ideal for debugging permission issues ### repl, repl-stdin creates a prompt and executes the same program for each line of user input. the input is used as additional arguments to the program. this way, the same command prefix does not have to be rewritten for each invocation and new arguments can just be pasted in. * usage: repl command argument ... * exit with ctrl+d or ctrl+c (sigint) * repl-stdin passes the user input to the standard input of the command #### examples create a file search field in the terminal: ~~~ repl find -name ~~~ display the character count for each entered line: ~~~ repl-stdin wc -c ~~~ ### search search for a string inside files in the current directory and display the names of files where it is included multiple search words can be specified, which must all occur in one line. depends on [ripgrep](https://github.com/BurntSushi/ripgrep) ### searchl search for a string inside files in the current directory and display the names of files and lines where it is included depends on [ripgrep](https://github.com/BurntSushi/ripgrep) ### splice * merge contents of a directory into the current directory * considers duplicate filenames and automatically renames conflicts ## text ### comma-to-newline replaces commas with newlines ### compress-spaces ~~~ $ echo "this is a test" | compress-spaces ~~~ ~~~ this is a test ~~~ ### file-lines-set-operations ~~~ usage options ... file-path ... description applies set operations to the lines of files. each file representing one set. writes the resulting lines to standard output options --complement | -c --difference | -d --help | -h show this help text --interface show a machine readable cli specification --intersection | -i --union | -u ~~~ ### lines-filter ~~~ parameters options ... strings ... description read from standard input and filter lines case-insensitively by given strings or regular expressions options --and matching lines must contain all strings. the default --case-sensitive | -c --help | -h --interface --negate --or matching lines must contain any of the strings --regexp | -r interpret strings as posix extended regular expressions ~~~ ### lines-reject like "lines-filter" but lists only the lines where none of the given strings match ### lowercase convert all uppercase characters in a string read from standard input to lowercase characters $ echo TEsT | lowercase ~~~ test ~~~ ### newline-to-comma like newline-to-space but converts to comma-separated entries $ ls / | newline-to-comma ~~~ bin, boot, dev, etc, home, lib, lib64, lost+found, mnt, opt, proc, root, run, sbin, srv, sys, tmp, usr, var ~~~ ### newline-to-space * converts newline separated lines to space separated entries * possible enhancements: quote results if they contain spaces $ ls / | newline-to-space ~~~ bin boot dev etc home lib lib64 lost+found mnt opt proc root run sbin srv sys tmp usr var ~~~ ### remove-double-newlines $ cat textfile | remove-double-newlines ### split-select select whitespace separated columns of newline separated lines by index. indices start at 0. other delimiters than whitespace can be used with the -d option. ~~~ arguments: [-d delimiter] index ..." ~~~ ## time ### day-seconds display the current seconds of the day ### hms-time display the current time in the format hh:mm:ss ### iso-date display the current iso date $ iso-date ~~~ 2015-11-15 ~~~ ### iso-week-number $ iso-week-number ~~~ 46 ~~~ ### posixtime display a unix timestamp ### posixtime-to-date convert a unix timestamp to the common date and time format. $ posixtime-to-date 1342342344 ~~~ 2012-7-15 10:52:24 ~~~ ### tzdate show date and time in all filtered time zones. lists all timezone times when run without arguments $ tzdate europe/a ~~~ Europe/Athens Wed 2015-11-18 21:50:27 Europe/Amsterdam Wed 2015-11-18 20:50:27 Europe/Andorra Wed 2015-11-18 20:50:27 ~~~ $ tzdate us/a ~~~ US/Aleutian Wed 2015-11-18 09:51:39 US/Arizona Wed 2015-11-18 12:51:39 US/Alaska Wed 2015-11-18 10:51:39 ~~~ ### year-week-count displays the number of weeks of the current week, the iso week date. depends on ruby $ year-week-count ~~~ 53 ~~~ ## other ### git-log a compact "git log" format ~~~ tantalum@online.de 2014-08-14 - c640774 M sph/cli.scm M sph/lang/scm-format.scm M sph/lang/scm-format/format.scm tantalum@online.de 2014-08-15 cli: proper required argument checking for patterns and an extended missing arguments exception. system-reader: simplified reader. lang-scm-format: fixes for some known issues a184459 M sph/cli.scm M sph/lang/scm-format.scm M sph/list.scm M sph/system/reader.scm M test/general/cli.scm M test/general/list.scm tantalum@online.de 2014-08-15 - f472c3f M sph/cli.scm ~~~ ### with-dialog-and-delay show a yes/no dialog on the command-line and only execute command when the answer is yes. can be used to wrap highly consequential system commands, to prevent them from being executed accidentally. usage: with-dialog-and-delay command ... #### example $ with-dialog-and-delay echo test ~~~ are you sure? [y/N] waiting 5 seconds... command execution started test ~~~ # 2 experimental and less useful scripts. care should be taken, and the file content reviewed, before executing these commands to avoid unexpected consequences ## convert ### binary $ echo test | binary ~~~ 1110100 1100101 1110011 1110100 1010 ~~~ ### freemind2indent create an indented tree from the freemind .mm format ### hex $ echo test | hex ~~~ 74 65 73 74 a ~~~ ## filesystem ### tidyfiles automatically sort files into directories by file type ### rename-lowercase * renames file to have an all lowercase filename. overwrites any existing paths * $ touch TEST TEST-2 * $ rename-lowercase TEST TEST-2 * $ ls ~~~ test test-2 ~~~ ### move-and-link ~~~ parameters options ... target-directory source-path ... description move files and replace the source paths with symlinks to the move destination options --help | -h --interface --keep-directory-structure? | -k ~~~ ### merge-files merge files, automatically create a non-existing target filename from the source filenames and check if the result file size matches the summarised size of the source files ### get-unique-path displays a filename that does not exist * $ touch /tmp/t.scm * $ unique-path /tmp/t.scm ~~~ /tmp/t.scm.1 ~~~ * $ touch /tmp/t.scm.1 * $ unique-path /tmp/t.scm ~~~ /tmp/t.scm.2 ~~~ ### display-relative-path-up ### file-size-sum displays the sum of content-bits of files from newline separated paths read from standard-input ### format-encrypt an example-script to setup an encrypted device for use with luks. better regard this as just an example. the commands used in it could completely destroy your filesystem if used incorrectly ### gui-tag-add like "tag-add" but uses a graphical dialog for entering new words ### gui-tag-remove like "tag-remove" but uses a graphical dialog for entering new words ### lf lists files in the current directory whose names include the given strings, sorted and colored by size ### tag-add :: name[.name ...] target-file ... the dot-separated words will be appended to all files given as arguments. no duplicates are added ### tag-remove :: name[.name ...] target-file ... the dot-separated words will be removed from all files given as arguments. the last name can not be removed ### tag-sort :: target-file ... sorts the strings alphabetically in all files given as arguments. prepend-to-filename ## programming ### coffee-compile uses "coffee" to compile coffeescript read from standard input ### compress-js uses "uglifyjs" to compress javascript ### javascript-format format javascript source code. can be called from emacs to have a powerful auto formatter. depends on "uglifyjs" ### javascript-format-add-function-spacing ### javascript-remove-semicolons ### lines-to-scheme-data ### scm-doc ## text ### remove-hash-comment-lines ### itpn featureful tagged note format processor. searches inside, filters, and processes text files where notes are written in indented blocks. for example: ~~~ tag1 tag2 this is text more text more note text tag3 this is another note ~~~ $ itpn --help ~~~ parameters options ... file-paths ... options --add-file-name-tags --count --deduplicate --exclude | -e --format=value prefix/suffix/filename. comma-separated names of block parts to display. default: prefix,suffix --help | -h --interface --list-unique-tags --output-file-1=value path for a file to write matches to --output-file-2=value path for a file to write non-matches to --output-to-source overwrite source files when output would otherwise be written to standard-output --replace-tag=value value format: "tags-to-replace replacements" "tag[.tag] tag[.tag]" --replace-tags-from-file=value takes a path to a file that contains lines in the format "tag replacement ..." --search=value | -s value search in the prefix part of itpn packets. conditions like word,word.~word.word are supported, where comma is "or", period is "and" and tilde is "not" --search-all=value | -a value --search-suffix=value --sort-packets --sort-tags --split split into matches and non-matches. output-file-1 receives matches, output-file-2 non-matches, and if any of those is not specified output is written to standard output --syntax-check | -c ~~~ ### alternate-text-direction * reverses text direction for every even line * considers punctuation * this way text can be read from left to right and right to left alternatingly, avoiding the need to look back to the left like a typewriter when reaching the end of a line ### camelcase-to-dashes $ echo camelCaseString | camelcase-to-dashes ~~~ camel-case-string ~~~ ### decapitalize remove capitalisation from words read on standard-input. ### file-lines-intersection ### ls-file-size ### randomize-lines randomizes the order of lines read from standard input. $ cat testfile | randomize-lines ~~~ test-3 test-2 test-4 test-1 ~~~ ### remove-iso-date-prefix-zeros $ echo 2015-05-03 | remove-iso-date-prefix-zeros ~~~ 2015-5-3 ~~~ ### string-binary displays the bits a string read from standard input is encoded in. $ echo abc | string-binary ~~~ 1100001 1100010 1100011 1010 ~~~ string-base16 and string-base32 work similarly. ## time-display ### ks-time show the current days elapsed kiloseconds ### ks-to-hms hms-to-ks convert kiloseconds to traditional hh:[mm:ss] time and back $ ks-to-hms 32 ~~~ 8:53:20 ~~~ $ hms-to-ks 15 ~~~ 54 ~~~ can also read text from standard input, where it replaces all occurrences of hh:mm[:ss] patterns with kilosecond values, optionally only in parentheses ### uptime-duration-ks displays the kiloseconds that have elapsed since the system has booted ### uptime-start-ks displays the day kiloseconds of when the system has been booted ## media ### youtube-dl-with-date download videos from youtube with a filename that includes upload date, video id and title. without a date in the name, it would be tedious to figure out when a video was uploaded. depends on [youtube-dl](https://ytdl-org.github.io/youtube-dl), which is also available in some package repositories. ### prepend-video-tags, prepend-video-tags-with-duration prepend "{pixel-height}p{frames-per-second}." to file names. using the --with-duration option also prepends a duration clasifier. d1 - under ~8 minutes, d2 - under ~42 minutes, d3 - over ~42 minutes, d4 - over ~83 minutes. ~~~ $ prepend-video-tags path ... ~~~ remove-video-tags removes the tags. ### prepend-image-size prepend "{pixel-height}." to image file names. currently only works with png and jpg ### create-video-from-png-images * create-video-from-png-images :: path-directory [skip-resize?] * creates a video from a directory filled with png files * if skip-resize? is "true", then it is assumed that the resize-pass has already run and resized pictures are available in the $source/edit directory. this speeds up the compilation process significantly ### video-thumbnails-image, video-thumbnails-images, show-video-thumbnails-image * video-thumbnails-image output-directory video-path ... * video-thumbnails-images output-directory video-path ... * show-video-thumbnails-image video-path creates images with thumbnails as a preview of video contents. generates an image for each given file path or all files in given directory paths. depends on ffmpeg and https://gitlab.com/movie_thumbnailer/mtn ### get-audio-disc-files read files from an audio disc and save them as pcm wave in the current directory or a specified directory. depends on "cdparanoia". ### split-flac-cue * split-flac-cue :: path-file-cue path-file-flac * split a flac file corresponding to a cue file * depends on "shnsplit" from "shntool" ### scale-images * scale :: width * scales all png or jpg images in a directory. a new directory "edit" is created where result images are put * depends on "graphicsmagick" ## other ### golden-ratio displays a list of numbers in the golden-ratio above and below the input number ~~~ 199.005 199.00502493123727 122.992 122.99186934331752 76.013 76.01315559640044 46.979 46.97871375215843 29.034 29.03444184748134 17.944 17.944271906679102 11.09 11.090169942039552 6.854 6.8541019654042525 4.236 4.23606797710791 2.618 2.6180339885884316 1.618 1.6180339887 0.618 0.618033988768953 0.382 0.3819660112736623 0.236 0.2360679775216284 0.146 0.14589803376831154 0.09 0.09016994376337698 0.056 0.05572809001115205 0.034 0.03444185375606755 0.021 0.021286236257459373 0.013 0.013155617500075927 0.008 0.008130618758290567 0.005 0.00502499874234599 ~~~ ### scm-format format scheme code. depends on sph-lib ### http-status display the http-status code for an url ### take-screenshots-in-intervals creates a screenshot every n seconds and saves it in a configured directory. depends on "scrot" ### cpioc create a cpio archive by reading paths from standard-input ### cpioe extract a cpio archive in the current directory ### dwm-show-info show time, weekday, and date in the dwm status bar. to keep running in the background: ~~~ dwm-show-info & ~~~ ### e pass all arguments to the program of the $EDITOR environment variable. ### g short alias for grep ### git-push do not write a commit messages and immedialy commit and push all changes. the commit message will be "-". ### git-stati execute "git status" for every directory in the current directory ### gui-md5sum display the md5sums of one or multiple files given as arguments in a graphical dialog window. depends on "zenity" ### mariadb-create-user-database-sql * mariadb-create-user-database-sql :: database [username password] * create the sql to create a database in mariadb and a user that has all privileges on the database. * username and password are optional. if username is ommited it is set to the database name. * if password is ommitted it is set to the username. ### take-screenshot * create a screenshot of all monitors in a configured directory * depends on "scrot" ### take-screenshot-window * create a screenshot of the currently focused window in a configured directory, with the filename being the posixtime at creation * depends on "scrot" ### show-process-memory-usage-top * lists the 10 active processes which currently use the most memory * the first part is the size of the used memory in mebibits, the second the process id ~~~ 1398 9105 firefox 308 877 emacs --daemon 300 914 /usr/bin/mpd --no-daemon 291 867 /usr/bin/Xorg.bin -nolisten tcp :0 -auth /tmp/serverauth.vqZ57dCRUR vt1 199 6121 sakura 177 1416 sakura 176 6957 sakura 114 4355 /usr/lib/polkit-1/polkitd --no-debug 108 9149 /usr/bin/guile /home/username/exe/show-process-memory-usage-top 66 4352 /usr/lib/upower/upowerd ~~~ ### ssh-install-key * ssh-install-key :: full-key-name remote-host-uri * install an ssh public key on the remote server * depends on the official "ssh-copy-id" ### take-website-screenshot * create a screenshot of a website * usage: ./exe/take-website-screenshot url output-filename * this script lies under other/take-website-screenshots * it depends on nodejs and requires "npm install" to have been executed in the other/take-website-screenshots directory # possible enhancements * reduce script dependencies