A collection of all kinds of shell scripts
Organisation: | Copyright (C) 2008-2024 Olivier Boudeville |
Contact: | about (dash) hull (at) esperide (dot) com |
Creation date: | Sunday, August 17, 2008 |
Lastly updated: | Wednesday, September 4, 2024 |
Version: | 1.0.10 |
Status: | Stable |
Dedication: | Users and maintainers of Ceylan-Hull. |
Abstract: | The role of Hull is to concentrate various, generic-purpose convenience shell scripts, on behalf of the Ceylan project. |
The latest version of this documentation is to be found at the official Ceylan-Hull website (http://hull.esperide.org).
This Hull documentation is also available in the PDF format (see Ceylan-Hull-technical-manual-english.pdf), and mirrored here.
Here are a few scripts, sorted by themes, that may be convenient for at least some users.
Many of them can display their intended usage on the console by specifying them the -h / --help command-line option.
In each category, scripts are roughly sorted by decreasing interest/update status. The scripts that we deem the most useful are described more precisely at the end of this document.
As much as possible, we try to name these scripts functionally rather than in terms of tools, so that the implementation they rely upon can be updated as transparently as possible (i.e. with as little change as possible in the user's habits).
These scripts are intended for all kinds of Unices, especially GNU/Linux, yet most of them are believed to work on Windows as well, provided a relevant context exists there.
Each script entry is a link pointing directly to the script itself. They may be directly obtained as a whole from the Hull repository.
Most of them are certainly not rocket science.
Note
A few of these scripts may be a bit outdated, as not all of them are daily used; rely on them with (a bit of) caution! (and tell us if you would like some of them to be updated).
- dci: assists efficiently and conveniently the commit of specified file(s)
- dci-all: selects recursively from current directory the files that should be committed (either added or modified), and commits them; for each of the modified files, shows the diff with previous version before requesting a commit message
- dif: shows on the console the differences between the current versions of the (possibly specified) files on the filesystem and the staged ones (i.e. the changes that might be added)
- difg: graphical version of dif
- dif-prev.sh: compares the current (committed) version of specified file(s) with their previous one
- difs: shows the differences between the staged files and their committed version
- st: shows the current VCS status of the specified files
- up: updates the current local version of the VCS repository
- show-branch-hierarchy.sh: shows the hierarchy of the branches in the current VCS repository
- list-tags-by-date.sh: lists, for the current VCS repository, all (annotated) tags, from the oldest one to the latest one
- list-largest-vcs-blobs.sh: lists the largest blob objects stored in the current VCS repository, sorted by decreasing size
- list-lastly-updated-vcs-branches.sh: lists, assuming to be in a clone, the VCS local or remote branches from the most recently modified one to the ones that were modified a longer time ago
- co-main.sh: performs a checkout of the main branch, regardless of its actual name (main or master)
- for the management of credentials (i.e. sets of login/password pairs):
- open-credentials.sh: unlocks (decrypts) the credential file whose path is read from the user environment, and opens it; once closed, re-locks it (with the same passphrase)
- lock-credentials.sh: locks (encrypts) the credential file whose path is read from the user environment
- unlock-credentials.sh: unlocks (decrypts) the credential file whose path is read from the user environment
- lock-screen.sh: locks immediately the screen
- suspend-local-host.sh: suspends immediately the local host, and ensures that it will resume in a locked state
- inspect-opened-ports.sh: lists the local TCP/UDP ports that are currently opened
One may also rely on Myriad's generate-password.sh script in order to generate safe, strong passwords (typically one per account listed based the *-credentials.sh scripts just above).
On a side note, we also recommend registering a domain name of one's own (e.g. myfoobar.org) and settting up a catch-all regarding the recipient email addresses (so that all emails sent to *@myfoobar.org are routed to your own personal email address).
Then, to avoid messing with your wildcard naming in terms of email addresses, you may choose first any conventional, meaningless email address prefix (e.g. deneb) to be dedicated to per-service communications. Next step is, in order to register to any online service (let's say it is named http://someacme.com), to declare to this service that your email address is deneb-someacme@myfoobar.org (or perhaps deneb-someacmedotcom@myfoobar.org if some ambiguity could remain). You would then generate a corresponding password with generate-password.sh and store the email/password pair among the credentials managed by the scripts above.
The advantages of this procedure as a whole are: strong and unique password, stronger pair of credentials as the login is not constant (hence less predictable ), and if ever you start receiving spam targeted to deneb-someacme@myfoobar.org then the corresponding website (e.g. http://someacme.com) may have some explanations to share...
See also Ceylan's HOWTO regarding cybersecurity.
- adb-pull.sh: uploads specified local files, possibly based on expressions to the already connected and authorizing Android device
- adb-push.sh: downloads in the current directory, from the already connected and authorizing Android device, files and directories (recursively)
- set-usb-tethering.sh: sets (or stops) USB tethering on local host, typically so that a smartphone connected through USB and with such tethering enabled shares its Internet connectivity with this host
See also the For MTP Devices section.
- archive-emails.sh: archives properly and reliably (compressed, cyphered, possibly transferred) the user emails
- Manages reference version of files, by storing them in a "vault":
- catch.sh: stores a file in a vault directory and makes a symbolic link to it, so that even if current tree is removed, this file will not be lost
- retrieve.sh: retrieves at least one file already stored in vault by creating link towards it, from current directory
- update-directory-from-vault.sh: updates all files in specified directory from their vault counterparts
- make-git-archive.sh: makes a backup (as an archived GIT bundle) of specified project directory, stored in specified archive directory
- snapshot.sh: performs a snapshot (tar.xz.gpg archive) of specified directory
- list-for-backup.sh: enumerates in current directory all files, specifies their name, size and MD5 sum, and stores the result in a relevant file
- notify.sh: notifies the user about specified message, possibly with a title and a category
- timer-at.sh: requests to trigger a timer notification at specified (absolute) timestamp
- timer-in.sh: requests to trigger a timer notification in specified duration
- timer-every.sh: requests to trigger (indefinitely, just use CTRL-C to stop) a timer notification every specified duration
- start-jam-session.sh: starts a jam session interrupted by a notification every period, to avoid remaining still for too long
- bong.sh: plays the specified number of bong sound(s)
- beep.sh: plays a beep to notify the user of an event
To facilitate shell sessions:
- mo: shorthand for a relevant version of more
- hide.sh: hides specified file or directory (simply by adding a -hidden suffix to its filename), while unhide.sh does the reverse operation
- set-display.sh: sets the X display to specified host; if none is specified, sets it to the local one
- get-date.sh: returns the current date in our standard short format (e.g. 20210219)
- wh
wh (for "where"): searches (as a more user-friendly 'find') all files and directories matching <filePattern>, from <starting_directory> if specified, otherwise from current directory.
Usage: wh [-h|--help] [--verbose] [-q|--quiet] [--no-path] [--exclude-path <a directory>] <filePattern> [<startingDirectory>]
[-q|--quiet]: only returns file entries (no extra display); suitable for scripts (e.g. for f in $(wh -q 'foo*'); do...)
--no-path: returns the filenames without any leading path
--exclude-path DIR: excludes specified directory DIR from search
- regrep
regrep: recursive grep for the ones that lack it.
Usage: regrep [-v|--verbose] [-q|--quiet] [-f|--filenames-only] [-i|--insensitive] [-r|--restructured] [-e|--exclude ELEM]* <Expression to be found in files> [<Filter on files>]
-v or --verbose: be specifically verbose
-q or --quiet: be specifically quiet, just listing matches
-f or --filenames-only: display only filenames, not also the matched patterns, and if there are multiple matches in the same file, displays its filename only once (implies quiet); typically useful in scripts
-i or --insensitive: perform case-insensitive searches in the content of files, and also when filtering any filenames
-r or --restructured: use ReStructured text mode (skip tmp-rst directories, search only *.rst and *.rst.template files)
-e or --exclude ELEM: excludes the specified filesystem element (e.g. file or directory) from the search; as many -e/--exclude options as wanted can be specified
Example: regrep --exclude ./foo.dat --exclude ./backup-dir -i 'little red rooster' '*.txt'.
See also: ergrep (for searching specifically in Erlang files), pygrep (Python version), jgrep (Java version), jsgrep (Javascript version), jsxgrep (React JSX version) and cgrep (C version).
- srm
srm (for "secure rm"): stores deleted files/directories in a trash instead of deleting them directly, in order to give one more chance of retrieving them if necessary. Ensures that no two file elements can collide in trash so that all contents are preserved.
Usage: srm <files/directories to delete securely>
- the tests subdirectory, for a few tests of specific facilities provided here
- the mostly-obsolete subdirectory, for the scripts we deprecated
- our Emacs configuration (in Ceylan-Myriad)
Bugs, questions, remarks, patches, requests for enhancements, etc. are to be reported to the project interface (typically issues) or directly at the email address mentioned at the beginning of this document.
If you have information more detailed or more recent than those presented in this document, if you noticed errors, neglects or points insufficiently discussed, drop us a line! (for that, follow the Support guidelines).
In the hope that Ceylan-Hull will be of use for you as well!